1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Dice Probability

  1. Oct 19, 2012 #1
    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. jcsd
  3. Oct 19, 2012 #2

    berkeman

    User Avatar

    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?
     
  4. Oct 19, 2012 #3
    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.
     
  5. Oct 19, 2012 #4

    berkeman

    User Avatar

    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?
     
  6. Oct 19, 2012 #5
    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)
     
  7. Oct 19, 2012 #6

    berkeman

    User Avatar

    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?
     
  8. Oct 19, 2012 #7

    rcgldr

    User Avatar
    Homework Helper

    The mean and standard deviation of what? Perhaps the sum of the numbers on the two dice?
     
  9. Oct 19, 2012 #8
    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
     
  10. Oct 19, 2012 #9

    berkeman

    User Avatar

    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?
     
  11. Oct 19, 2012 #10
    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.
     
  12. Oct 20, 2012 #11

    vela

    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper
    Education Advisor

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

    Attached Files:

  14. Oct 20, 2012 #13

    vela

    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper
    Education Advisor

    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.
     
  15. Oct 20, 2012 #14
    Thank you so much. That's what I needed.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Dice Probability
  1. Dice Probability (Replies: 11)

  2. Dice and probability (Replies: 6)

  3. Probability with dice (Replies: 2)

Loading...