Solve Dice Probability Homework - Mean, Standard Deviation

  • Thread starter Thread starter iRaid
  • Start date Start date
  • Tags Tags
    Dice Probability
AI Thread Summary
The discussion focuses on simulating the rolling of two dice 100 times and calculating the mean and standard deviation from the results. The user is coding in Visual Basic and has successfully generated the data but struggles with the mathematical calculations. Key formulas for calculating the mean and standard deviation are provided, emphasizing the need to sum the results and apply the variance formula. The conversation highlights the importance of correctly implementing these formulas in the user's code or spreadsheet. The user expresses gratitude for the clarification on the calculations needed.
iRaid
Messages
558
Reaction score
8

Homework Statement



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 can't seem to figure out how to do this.. Seems simple right?

Homework Equations


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
 
Physics news on Phys.org
iRaid said:

Homework Statement



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 can't seem to figure out how to do this.. Seems simple right?

Homework Equations





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

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?
 
berkeman said:
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?

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 can't think of it.
 
iRaid said:
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 can't think of it.

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?
 
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)
 
iRaid said:
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)

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?
 
The mean and standard deviation of what? Perhaps the sum of the numbers on the two dice?
 
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
 
iRaid said:
The mean will be around 6... I looked at that not sure how to implement it into a set of data.

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
berkeman said:
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?

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
How did you end up calculating the mean? Describe what you did in detail. Calculating the standard deviation is pretty similar.
 
  • #12
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..?
 

Attachments

  • #13
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
vela said:
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.

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