(************** Content-type: application/mathematica ************** CreatedBy='Mathematica 5.2' Mathematica-Compatible Notebook This notebook can be used with any Mathematica-compatible application, such as Mathematica, MathReader or Publicon. The data for the notebook starts with the line containing stars above. To get the notebook into a Mathematica-compatible application, do one of the following: * Save the data starting with the line of stars above into a file with a name ending in .nb, then open the file inside the application; * Copy the data starting with the line of stars above to the clipboard, then use the Paste menu command inside the application. Data for notebooks contains only printable 7-bit ASCII and can be sent directly in email or through ftp in text mode. Newlines can be CR, LF or CRLF (Unix, Macintosh or MS-DOS style). NOTE: If you modify the data for this notebook not in a Mathematica- compatible application, you must delete the line below containing the word CacheID, otherwise Mathematica-compatible applications may try to use invalid cache data. For more information on notebooks and Mathematica-compatible applications, contact Wolfram Research: web: http://www.wolfram.com email: info@wolfram.com phone: +1-217-398-0700 (U.S.) Notebook reader applications are available free of charge from Wolfram Research. *******************************************************************) (*CacheID: 232*) (*NotebookFileLineBreakTest NotebookFileLineBreakTest*) (*NotebookOptionsPosition[ 9726, 275]*) (*NotebookOutlinePosition[ 10399, 298]*) (* CellTagsIndexPosition[ 10355, 294]*) (*WindowFrame->Normal*) Notebook[{ Cell["Laboratory 04", "Title"], Cell["October 7, 2005", "Subsubtitle"], Cell[BoxData[ \(Clear["\"]\)], "Input"], Cell[CellGroupData[{ Cell["1.", "Subsubsection"], Cell["\<\ Read in the dataset and, at the same time, put it into a Table with \ appropriate dimensions to group the data into lists with three \ elements.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(\(\[IndentingNewLine]\)\(\(RWData = ReadList["\", Table[Number, {3}]];\)\[IndentingNewLine] Dimensions[RWData]\)\)\)], "Input"], Cell[BoxData[ \({8000, 3}\)], "Output"] }, Open ]], Cell["Look at the first few rows of data:", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Do[Print[RWData[\([kk]\)]], {kk, 4}]\)], "Input"], Cell[BoxData[ \({0.5`, 25, 1014}\)], "Print"], Cell[BoxData[ \({0.5`, 50, 3108}\)], "Print"], Cell[BoxData[ \({0.5`, 75, 57012}\)], "Print"], Cell[BoxData[ \({0.5`, 100, 16114}\)], "Print"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["2.", "Subsubsection"], Cell["\<\ Initialize Lists that will store data. I use two nested Do loops to \ accomplish this in a single step.\ \>", "Text"], Cell[BoxData[ \(Do[Do[NumSteps[ii, jj] = {}, {ii, 0.5, 2. , 0.5}], {jj, 25, 100, 25}]\)], "Input"], Cell[CellGroupData[{ Cell[BoxData[ \(NumSteps[0.5, 50]\)], "Input"], Cell[BoxData[ \({}\)], "Output"] }, Open ]], Cell["\<\ Now write a somewhat more ambitious routine to examine each row of \ data and place the number of steps into the appropriate list that we've \ initialized.\ \>", "Text"], Cell["\<\ First define a function that will examine a given row of data and \ write the number of steps to the corresponding data set:\ \>", "Text"], Cell[BoxData[ \(AddStepsToList[StepLength_, BorderPos_] := \ If[\(RWData[\([NRow]\)]\)[\([1]\)] \[Equal] \ StepLength\ && \(RWData[\([NRow]\)]\)[\([2]\)] \[Equal] \ BorderPos, AppendTo[ NumSteps[StepLength, BorderPos], \(RWData[\([NRow]\)]\)[\([3]\)]]]\)], "Input"], Cell["\<\ Next, define a function that will sort the data one row at a time \ until all 8000 rows are completed. Note use of nested Do loops that enable \ access to all 16 data sets we need to collect.\ \>", "Text"], Cell[BoxData[ \(SortDataSet[NRow_] := Do[Do[AddStepsToList[StepLength, BorderPos], {StepLength, 0.5, 2.0, 0.5}], {BorderPos, 25, 100, 25}]\)], "Input"], Cell["Now sort all the data and check one data set:", "Text"], Cell[BoxData[ \(Do[SortDataSet[NRow], {NRow, 8000}]\)], "Input"], Cell[CellGroupData[{ Cell[BoxData[{ \(NumSteps[0.5, 25]\), "\[IndentingNewLine]", \(Dimensions[%]\)}], "Input"], Cell[BoxData[ \({1014, 970, 1490, 2800, 3806, 938, 1262, 4164, 1742, 924, 3000, 1384, 8212, 2522, 8486, 812, 3310, 2088, 2700, 2952, 1548, 6302, 1056, 2742, 7012, 1604, 6290, 1440, 5190, 2194, 826, 752, 962, 3676, 4528, 3474, 534, 1936, 4282, 2298, 1214, 2580, 2614, 4936, 1536, 572, 1840, 1682, 1938, 1500, 2190, 5188, 3678, 2540, 1916, 5766, 4048, 3054, 474, 798, 4198, 1528, 1330, 1220, 2248, 3982, 4672, 5124, 3710, 912, 2704, 604, 1078, 1236, 906, 1636, 784, 2924, 4700, 6220, 1036, 868, 1028, 1596, 854, 500, 4184, 1816, 1546, 1682, 1576, 442, 3620, 4012, 1986, 7342, 5116, 2892, 1550, 2104, 990, 2438, 1082, 1094, 4092, 7716, 3630, 2332, 1358, 3450, 1474, 1540, 1494, 4302, 3124, 2240, 1026, 752, 2362, 1420, 1480, 4728, 204, 2164, 522, 7886, 794, 1194, 480, 2786, 978, 2978, 1830, 1066, 742, 6074, 3282, 1490, 1964, 2662, 170, 2444, 4102, 3100, 1252, 2088, 5848, 1584, 10834, 3968, 8816, 4068, 3278, 738, 1474, 590, 3962, 3402, 554, 978, 1982, 2704, 1646, 4082, 1450, 1382, 2314, 1706, 6948, 500, 2448, 2694, 266, 1626, 2292, 406, 2272, 1930, 1430, 3510, 948, 1524, 276, 814, 1942, 750, 888, 1116, 3940, 2250, 1736, 1070, 1212, 1514, 418, 5162, 7380, 1154, 3020, 3088, 1554, 3018, 1884, 538, 1276, 5654, 2272, 1050, 776, 1528, 868, 1882, 1130, 3688, 1244, 3446, 1940, 3640, 2544, 1724, 4494, 2150, 710, 2278, 11486, 558, 1116, 3512, 1578, 2184, 8360, 2168, 1766, 1564, 802, 1280, 2890, 882, 4144, 908, 3494, 5070, 1018, 6542, 5052, 1082, 1604, 4298, 2378, 508, 1744, 1206, 2020, 1270, 884, 4660, 2070, 3118, 890, 2982, 802, 356, 3624, 986, 6652, 858, 1752, 2404, 6000, 2330, 784, 3394, 2822, 4180, 518, 1266, 1310, 2650, 3388, 3320, 4572, 1096, 1156, 1512, 1398, 564, 1238, 4446, 3168, 6468, 2992, 2474, 2582, 5230, 1438, 1444, 4366, 1662, 2218, 1920, 3004, 1286, 1612, 1890, 1270, 1208, 450, 11960, 1330, 3674, 632, 702, 2458, 996, 8568, 1806, 1054, 2818, 2824, 5436, 610, 1154, 974, 3228, 3162, 842, 4354, 394, 636, 3130, 326, 5610, 3156, 1020, 2698, 3698, 1750, 898, 902, 1090, 3064, 3316, 6208, 1944, 4430, 948, 4602, 948, 10362, 1814, 658, 7202, 1034, 2980, 2080, 632, 4250, 318, 1388, 2250, 3974, 3486, 7220, 1554, 1878, 1252, 1752, 3044, 768, 534, 2164, 826, 2940, 6646, 2556, 1426, 1444, 6792, 4968, 2512, 442, 5956, 3900, 2504, 8172, 5788, 1444, 1552, 1756, 2146, 2420, 4912, 3460, 988, 1014, 1592, 3158, 2288, 5774, 1298, 1530, 3430, 1750, 4544, 822, 1550, 1168, 1522, 1276, 2344, 1682, 964, 1848, 1942, 1676, 3414, 1980, 4250, 416, 1988, 1226, 4342, 654, 5262, 592, 1440, 2350, 3614, 1732, 2912, 3580, 1584, 2348, 1308, 2696, 1816, 392, 3654, 1472, 5050, 984, 1274, 1908, 1320, 4978, 4640, 4448, 860, 3296, 778, 5302, 748, 2250, 1236, 7216, 4400, 2456, 834, 2504, 4708, 4070, 2792, 1324, 2210, 718, 1524, 960, 11292, 5934, 4614, 2408, 638, 3766, 6056, 1438, 3654, 2186, 1016, 2516, 3448, 1284, 5390, 1294, 3858, 892, 752, 2366, 318, 952, 2962, 2360, 1740, 4610, 1790, 1942, 570, 1050, 1750, 1520, 4810}\)], "Output"], Cell[BoxData[ \({500}\)], "Output"] }, Open ]], Cell["\<\ OK, this looks good because there are 8000 rows of data to be \ sorted into 16 data sets, making the number of steps per dataset equal to \ 500.\ \>", "Text"] }, Open ]], Cell[CellGroupData[{ Cell["3.", "Subsubsection"], Cell[BoxData[ \(<< Graphics`MultipleListPlot`\)], "Input"], Cell["\<\ To make the desired plots, we need to compose four data sets of the \ form {BorderPos,NoOfSteps}, one data set for each BorderPos.\ \>", "Text"], Cell[BoxData[ \(Results[ StepLength_] := {{25, Mean[NumSteps[StepLength, 25]]}, {50, Mean[NumSteps[StepLength, 50]]}, {75, Mean[NumSteps[StepLength, 75]]}, {100, Mean[NumSteps[StepLength, 100]]}}\)], "Input"] }, Open ]], Cell[CellGroupData[{ Cell["4.", "Subsubsection"], Cell["\<\ Now repeat the process but this time include both the mean values \ and the standard deviations (in the form of \"error bars\") in the data set \ for plotting:\ \>", "Text"], Cell[BoxData[ \(ResultsEBars[ StepLength_] := {{{25, Mean[NumSteps[StepLength, 25]]}, ErrorBar[StandardDeviation[NumSteps[StepLength, 25]]]}, {{50, Mean[NumSteps[StepLength, 50]]}, ErrorBar[StandardDeviation[NumSteps[StepLength, 50]]]}, {{75, Mean[NumSteps[StepLength, 75]]}, ErrorBar[StandardDeviation[NumSteps[StepLength, 75]]]}, {{100, Mean[NumSteps[StepLength, 100]]}, ErrorBar[StandardDeviation[NumSteps[StepLength, 100]]]}}\)], "Input"], Cell["\<\ Here is a data set for plotting just the standard deviations:\ \>", \ "Text"], Cell[BoxData[ \(ResultsStdDev[ StepLength_] := {{25, StandardDeviation[NumSteps[StepLength, 25]]}, {50, StandardDeviation[NumSteps[StepLength, 50]]}, {75, StandardDeviation[NumSteps[StepLength, 75]]}, {100, StandardDeviation[NumSteps[StepLength, 100]]}}\)], "Input"] }, Open ]] }, FrontEndVersion->"5.2 for Macintosh", ScreenRectangle->{{0, 1148}, {0, 746}}, WindowSize->{852, 564}, WindowMargins->{{4, Automatic}, {Automatic, 1}}, StyleDefinitions -> "3016_Carter.nb" ] (******************************************************************* Cached data follows. If you edit this Notebook file directly, not using Mathematica, you must remove the line containing CacheID at the top of the file. The cache data will then be recreated when you save this file from within Mathematica. *******************************************************************) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[1754, 51, 30, 0, 64, "Title"], Cell[1787, 53, 38, 0, 74, "Subsubtitle"], Cell[1828, 55, 54, 1, 50, "Input"], Cell[CellGroupData[{ Cell[1907, 60, 27, 0, 43, "Subsubsection"], Cell[1937, 62, 168, 4, 66, "Text"], Cell[CellGroupData[{ Cell[2130, 70, 190, 4, 90, "Input"], Cell[2323, 76, 43, 1, 52, "Output"] }, Open ]], Cell[2381, 80, 51, 0, 46, "Text"], Cell[CellGroupData[{ Cell[2457, 84, 69, 1, 50, "Input"], Cell[2529, 87, 49, 1, 42, "Print"], Cell[2581, 90, 49, 1, 42, "Print"], Cell[2633, 93, 50, 1, 42, "Print"], Cell[2686, 96, 51, 1, 42, "Print"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[2786, 103, 27, 0, 43, "Subsubsection"], Cell[2816, 105, 127, 3, 46, "Text"], Cell[2946, 110, 111, 2, 50, "Input"], Cell[CellGroupData[{ Cell[3082, 116, 50, 1, 50, "Input"], Cell[3135, 119, 36, 1, 52, "Output"] }, Open ]], Cell[3186, 123, 179, 4, 66, "Text"], Cell[3368, 129, 148, 3, 66, "Text"], Cell[3519, 134, 335, 7, 90, "Input"], Cell[3857, 143, 215, 4, 66, "Text"], Cell[4075, 149, 175, 3, 90, "Input"], Cell[4253, 154, 61, 0, 46, "Text"], Cell[4317, 156, 68, 1, 50, "Input"], Cell[CellGroupData[{ Cell[4410, 161, 99, 2, 70, "Input"], Cell[4512, 165, 3226, 42, 1064, "Output"], Cell[7741, 209, 39, 1, 52, "Output"] }, Open ]], Cell[7795, 213, 168, 4, 66, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[8000, 222, 27, 0, 43, "Subsubsection"], Cell[8030, 224, 62, 1, 50, "Input"], Cell[8095, 227, 154, 3, 66, "Text"], Cell[8252, 232, 253, 5, 130, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[8542, 242, 27, 0, 43, "Subsubsection"], Cell[8572, 244, 183, 4, 66, "Text"], Cell[8758, 250, 537, 9, 210, "Input"], Cell[9298, 261, 87, 3, 46, "Text"], Cell[9388, 266, 322, 6, 130, "Input"] }, Open ]] } ] *) (******************************************************************* End of Mathematica Notebook file. *******************************************************************)