# Homework Help: Dice Probability

1. Oct 19, 2012

### iRaid

1. The problem statement, all variables and given/known data

Well I need to design a program that simulates rolling 2 dice. After the dice have been rolled 100 times, I need to find the mean and standard deviation of each (from the data that I get from the simulation). I cant seem to figure out how to do this.. Seems simple right?

2. Relevant equations

3. The attempt at a solution

Lead me in the right direction, thanks lol.

Edit if it's not clear...

The data is as shown:
Number-Frequency
2-w/e
3-w/e
4-w/e
5-w/e
6-w/e
....so on

2. Oct 19, 2012

### Staff: Mentor

Yes, it does seem pretty straightforward. What computer language are you coding in? C? Excel? Other?

How do you generate a random number in that language? There should be some sort of random number function call...

So can you at least do the part that generates the pair of random numbers and adds them up?

And what sort of array would you declare to store the results in?

3. Oct 19, 2012

### iRaid

It's in visual basic and I have it done, I just need to figure out the math behind it, it seems easy I just cant think of it.

4. Oct 19, 2012

### Staff: Mentor

Can you post your code? Be sure to use "code" tags to preserve the indentations.

What math are you asking about? How to generate random numbers? How to calculate a Mean and Standard Deviation?

5. Oct 19, 2012

### iRaid

I'd rather not post the code. All it does is generate data from the number you role and the frequency it is rolled. (100 times)

The only thing I need is how to calculate the mean and standard deviation from data. (For example, if you had a excel sheet with both of those, how would I calculate the mean and standard deviation)

6. Oct 19, 2012

### Staff: Mentor

In Excel, there are standard math functions that you can use to calculate Mean and Standard Deviation of a selected group of cells.

In many programming languages, there will be library function calls that you can use. But it sound like in this assignment you are supposed to just do it with basic math operations. Here is how you do it:

http://en.wikipedia.org/wiki/Standard_deviation

BTW, what do you predict the Mean will be?

7. Oct 19, 2012

### rcgldr

The mean and standard deviation of what? Perhaps the sum of the numbers on the two dice?

8. Oct 19, 2012

### iRaid

The mean will be around 6... I looked at that not sure how to implement it into a set of data.

@rcgldr, I'm not sure what either, the example has 6.7 as the mean and standard deviation as 2.5 so I really don't know

9. Oct 19, 2012

### Staff: Mentor

What do you mean you're not sure? The Mean calculation is easy, right? Just add up the 100 roll results and divide by what?

And the wikipedia page shows how to calculate the Standard Deviation. Why can't you just do that on your data? Do you store the data in an array?

10. Oct 19, 2012

### iRaid

The standard deviation is my only problem, I have never done it in math before and I see the formula and understand it, just not when applied to a set of data (I've done calc tho..).

And yes my data is in an array.

11. Oct 20, 2012

### vela

Staff Emeritus
How did you end up calculating the mean? Describe what you did in detail. Calculating the standard deviation is pretty similar.

12. Oct 20, 2012

### iRaid

I attached an excel sheet with what I did, the standard deviation is wrong, I'm not sure how to do it manually (without excel commands)

Can someone tell me what's wrong..?

#### Attached Files:

• ###### meanstd.xls
File size:
20.5 KB
Views:
71
13. Oct 20, 2012

### vela

Staff Emeritus
OK, to calculate the mean, you did this:
$$\bar{x} = \frac{x_1 + x_2 + \cdots + x_N}{N} = \frac{n_2\times 2 + n_3 \times 3 + n_4 \times 4 + \cdots + n_{12} \times 12}{N}$$ where N is the total number of rolls and nx is the number of times you rolled x. It makes sense, right? You rolled a two n2 times, so it contributes $2\times n_2$ to the total and so on.

Now the standard deviation is the square root of the variance $\sigma^2$, and the variance is given by
$$\sigma^2 = \frac{(x_1 - \bar{x})^2 + (x_2 - \bar{x})^2 + \cdots + (x_N - \bar{x})^2}{N} = \frac{n_2\times(2-\bar{x})^2 + n_3\times(3-\bar{x})^3 + \cdots + n_{12}\times(12-\bar{x})^2}{N}.$$ Again, this should make sense. There will be n2 terms in the numerator which equal $(2-\bar{x})^2$ and so on. Compare that last formula to what you're calculating on your spreadsheet, and you should see that you're not implementing the formula correctly.

14. Oct 20, 2012

### iRaid

Thank you so much. That's what I needed.