• Post Reply Bookmark Topic Watch Topic
  • New Topic

Dice Probability - Nested Loops (No Arrays)  RSS feed

 
Greenhorn
Posts: 14
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(I managed to solve the problem on my own after a while)
 
Bartender
Posts: 2087
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

Instead of removing your post, you could tell us how you resolved your problem.
This way someone might learn something from you.
 
Ranch Hand
Posts: 147
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had a similar problem a while back (computing probabilities for an arbitrary number of different dice (with arbitrary number of sides), and am interested in how you solved this
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I could be incorrect (it's been a while since I took probability), but I think each dice could be modeled by a discrete uniform probability mass function (PMF), which would be an array of probabilities. If you want to find the PMF of the sum of the dice rolls, then you have to convolve all the dice PMF's together. To get the probability that you get a particular dice roll sum, evaluate the PMF of the sum of the dice rolls at that value. Maybe these calculations could be optimized to avoid the usage of arrays if you're only looking for the probability of one particular sum at a time, but I'm not sure.
 
Master Rancher
Posts: 2045
75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're correct.

But determining the (P)DF (or PMF) is not that easy. It makes for a nice problem though:

Given a Die class, with one member: number of sides, and a List of Dice,
give the PDF of this list. (i.e: for each possible outcome of a throw of all the dice
in the list, what is the chance of this outcome?).

Greetz,
Piet
 
Jan Hoppmann
Ranch Hand
Posts: 147
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My approach seems to be a bit more naïve (and rather long):

 
Damien Sky
Greenhorn
Posts: 14
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's mine:

 
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Damien Sky wrote:Here's mine:

I fear I've misunderstood the problem then. What probability is it that you're trying to work out?

I was working on the premise that it had something to do with the "sum" (assuming it's actually possible) being either equalled or exceeded in the given number of throws, which is likely to be a fixed value and have very little to do with random numbers at all.

Or are you trying to get the probability returned by a randomised test?

Winston
 
Piet Souris
Master Rancher
Posts: 2045
75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What Damien does is simply to approach the chances by using the so called 'Monte Carlo'
technique. Throw many times, and note how often you get a certain outcome. Nothing
wrong with that, it is just that we are used to getting exact outcomes in the case of
throwing dice, by simply counting how often we get a certain outcome.
This is not what we call (in Statistics) a 'randomized test'.

Greetz,
Piet
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Piet Souris wrote:What Damien does is simply to approach the chances by using the so called 'Monte Carlo' technique. Throw many times, and note how often you get a certain outcome. Nothing wrong with that, it is just that we are used to getting exact outcomes in the case of throwing dice, by simply counting how often we get a certain outcome.
This is not what we call (in Statistics) a 'randomized test'.

Fair enough, but it's what I meant . Now I understand.

Winston
 
Damien Sky
Greenhorn
Posts: 14
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My assignment said to use the Monte Carlo method, so that's why I did that.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!