Crash Course in working with Spreadsheets Spreadsheets can be really useful for doing calculations. Simple uses are computing the sum, the maximum, the mean, or the median of a number of values. 1. Computing the sum of a number of values a. Open a fresh spreadsheet. b. Notice that columns are labeled with letters, and rows are labeled with numbers. c. In column A, now enter in the first 5 rows the numbers 1, 3, 2, 6, 4 d. Select the cells A1 through A5 by clicking and holding cell A1 and dragging with your mouse over to A5, the cells should color blue. e. If youʼre using Google Spreadsheets, in the right bottom corner youʼll see the sum of this series (in Excel itʼll be in the right half of the status bar at the bottom of the window). f. Now, click cell A6 and type the command =SUM(A1:A5) (donʼt forget the = sign!) and press enter. Now youʼll see the sum of the cells A1 through A5 (which is indicated by the notation A1:A5) given in cell A6. g. If the cell A6 is selected (by clicking it once), youʼll notice that the command you just typed is in the formula bar just above the cells. Furthermore, you may notice a dash line demarcation of the cells A1 through A5 indicated in the same color as the expression A1:A5 in the formula. h. Try to get the MAX, MEDIAN, AVERAGE, and VAR (variance) in respectively cells A7, A8, A9, and A10 i. You can also use values that are present in one cell in the computation of the value in another: In cell B1 type the command =A1*A2+A3^2+A4/A5 and press enter. The value in the cell B1 should now be 1x3+22+6/4 = 8.5. 2. Generating sequences of numbers and of formulas a. Spreadsheets are ʻsmartʼ in that they can recognize a sequence from a few example values and generate more values: Enter the values 1, 3, 5 in the first three cells in column C. Now select those three cells by clicking and holding C1 and dragging the mouse down to C3. The three cells should turn blue (like earlier). Also thereʼs a small dark square at the bottom right of the selection. With your mouse, click and hold and drag down till cell C12. The cells until C12 should now be filled with subsequent values in the series (1, 3, 5, 7, 9, 11, etc.). b. Enter the values 1 and 2 in cell D1 and D2 respectively. By selecting these cells and dragging the little square at the bottom right of the selection, generate the sequence 1, 2, 3, ..., 30. c. The really powerful thing of spreadsheets is that they can also generate sequences of formulaʼs: In cell E1, type the command

=(D1 - 15)^2 + 3 and press enter. In column D you should now find a sequence of values that runs from 199 down to 3, and then back up again to 228. d. Click on any of the cells in column D (that have just been filled with numbers) and look at the expression in the formula bar. What do you notice in the formulas as you go from one cell to the next in column D? e. You can make a graph of the values in column D. To do so, select the cells D1:E30 (that is, click and hold cell D1 and drag down to D30 and then one cell to the right to end up at E30, the cells should turn blue). Now, click the graph icon on the tool bar (or choose ʻChartʼ from the ʻInsertʼ menu), and look for the Scatter plot (XY Scatter in Excel). Click ʻInsertʼ (ʻFinishʼ in Excel) to insert the graph in the spreadsheet. 3. Using a cell as a global variable a. In formulaʼs you can indicate the value of any cell in the spreadsheet (by specifying its column and row, such as A2 or B4), except the cell itself. So for instance, cell F3 cannot contain the formula =3*F3^3 Just try it, youʼll get an error message. For instance we can accumulate a series of values by referring to the previous cell and adding another value: In cell G1 type the formula =E1 and in cell G2 type the formula =G1 + E2 and press enter (notice that weʼre referring to the value in the previous row in column G as well as in the same row but in column E?). Now click cell G2, and drag the small square in the bottom right corner down to cell G30. The value in cell G30 should now be 2345. Verify that indeed cell G2 = E1+E2, G3 = E1+E2+E3, G4=E1+E2+E3+E4, etc. b. If you click any of the cells in column G and look at the formula bar, you again notice that the spreadsheet has been ʻsmartʼ in changing the cell references in the formula for us. Sometimes you donʼt want this, however. For instance, we can also calculate the values in column G as follows: In cell H1 type the command =SUM(\$E\$1:E1) and press enter. Now click cell H1 once, and drag the small square in the bottom right corner of the selection down to cell H30. The same values as in column G should now appear in column H. Click any of the cells in column H and investigate the formulas in the formula bar. Notice that in the formulas generated by the spreadsheet the \$E\$1 part in \$E\$1:E1 didnʼt change, while the part after the colon did change. The dollar signs (\$) can (and must) always be used to indicate a cell reference that mustnʼt be changed in generating a sequence of formulas.

If this doesnʼt work, you can try the formula =ROUND(6*RAND()+0.5,0)

ii. First select cells F1:F7 by clicking and holding F1 and dragging down to F7. These cells should now be blue. iii. Now start typing the command =FREQUENCY(D1:D100, E1:E6) and then hold the Ctrl and Shift keys down, and then press enter. (You need to press Ctrl and Shift while pressing Enter, because this is a so-called array formula, which means that an array is returned.) A sequence of values should now appear, ending with the value 0. (If in Excel this is not the case, you may need to select F1 and drag the small square down to F7.) iv.Select cells E1:F6 (just F1:F6 in Excel) and click the Chart icon in the tool bar. Choose the bar chart, and make sure the values in column E are used as labels for the x-axis. Also customize the y-axis range to go from 0 to 25. d. Is the shape of the histogram as expected? That is, what did you expect? And how does it deviate from what you expected? e. What accounts for the deviation from what you expect? f. How could you get it closer to what you expect? 3. Simulating Bernoulli trials a. RANDBETWEEN generates values that are uniformly distributed between the first and second argument (in the die experiment between 1 and 6). If we want to simulate a Bernoulli trial we want to be able to specify the probability of success. There is no built in function for generating Bernoulli trials, however. Fortunately we can use another random number generator, RAND, which generates real numbers between 0 and 1 in a uniform fashion: Create a fresh spreadsheet. In cell A1 type the formula =RAND() and press enter. By selecting and dragging generate more random values in the cells A2:A10. b. We can use this function to generate Bernoulli trials with the following trick: Suppose we would like to have success rate 1/3. In cell B1 type the following formula =IF( RAND() < 1/3, 1, 0) and press enter. This formula says â&#x20AC;&#x153;If (the random between 0 and 1 returned by RAND) is smaller than 1/3, the value is 1, else, the value is 0â&#x20AC;?. By clicking and dragging, generate Bernoulli observations in cells B2:B100. c. In cell C1 type the formula =AVERAGE(\$B\$1:B1) and press enter. Select C1 and drag the small dark box in the bottom right of the selected cell down to C100. d. Explain what is calculated by this sequence (refer back to the Crash course working with spreadsheets questions if necessary). What do you observe in the resulting sequence? e. Select cells C1:C100 and click the graph icon. Insert a Line Chart. What do you see happening in the chart as the number of values in the averages increases? How does the start of the series differ from the end of the series in terms of the variability? f. Using covariance calculus, try to explain analytically what is happening.