[ 3 / biz / cgl / ck / diy / fa / ic / jp / lit / sci / vr / vt ] [ index / top / reports ] [ become a patron ] [ status ]
2023-11: Warosu is now out of extended maintenance.

/sci/ - Science & Math


View post   

File: 53 KB, 378x226, Science fiction.jpg [View same] [iqdb] [saucenao] [google]
6496198 No.6496198[DELETED]  [Reply] [Original]

Hey /sci/.
Making something and need a little help with math. Math is your purview, right?

Anyway, little program to calculate dice probability. x y-sided dice, dropping the z lowest results; what's the average of that setup?
(eg, x=4, y=6, z=1; roll 4 six-sided dice, drop the lowest one.)

Is there a general formula for that? I tried to poke around but I don't think I know how to phrase it properly to get results from a search engine.

My current iteration has the computer run through a given setup a few thousand times to try and empirically simulate the average, but that's a lot more complex than I'd like it to be.

>> No.6496289

>>6496198
A convenient way to handle dice is to multiply polynomials. For an n-sided die, consider the polynomial <span class="math">p = x^{n} + x^{n-1} + \cdots + x^1 + 0[/spoiler]. Now for r rolls, calculate the coefficients of <span class="math">p^r[/spoiler].

Here is a 4-sided die
<span class="math">p = x^4 + x^3 + x^2 + x + 0[/spoiler]. Roll this die twice.
<span class="math">p^2 = x^{8}+2x^{7}+3x^{6}+4x^{5}+3x^{4}+2x^{3}+x^{2}[/spoiler]. This tells us there is one way to roll an 8 (namely, two fours), two ways to roll a 7 ({3,4} and {4,3}), and so on.

Enjoy.

>> No.6496292

Not sure if this works:
We vary a value i from 1 to y
we add to the solution:
[(i / y) ^ z] * [((y - i + 1) / y) ^ (x - z)] * [(y + i) / 2]

>> No.6496296

>>6496289
ooh nice, that's an interesting way to do it.
How does that work? I mean, what's the idea behind it? Is the x a 'dummy variable' such as in probability generating functions?

>> No.6496323

>>6496289
I don't get it. I'm sorry, I'm just slow when it comes to reading math.

Is p supposed to be the average result?

>> No.6496378

>>6496323
no, it's just a generator. But it will tell you how to weight your averages.

So if there are two ways to roll a 7, and you get to throw out your lowest result, then you'll get a 4 here two times, you see?

I didn't intend to solve the problem for you juswt show you a way that might help.

>> No.6496398

>>6496378

Darn. I don't think I have the math to be able to work this, honestly. As a piddling CS student, I think my best bet may be to go ask a math professor.

>>6496292
Thank you for the assistance, but I'm fairly certain that does not work. (Assuming I understand you properly.)

1d4 drop 0 == 6.5 (impossible)
2d4 drop 0 == 5.065 (incorrect; average of 2d4 should be 5-even)
2d6 drop 0 == 10.138888[8 repeating] --> should be 7.
3d6 drop 1 results in 3.851[851 repeating]

Either it doesn't work, or I entered it incorrectly.

>> No.6496469

>>6496398
What you want are order statistics.
See http://en.wikipedia.org/wiki/Order_statistic#Dealing_with_discrete_variables
That's the formula giving you the probability distribution for the z+1, z+2, ..., xth lowest values (f(x) here is just 1/y for x = 1, ..., y). To find the total expectation, just sum up the individual expectations of each order statistic over their range of possible values (i.e. 1 to y). Tedious, but fairly straightforward.

>> No.6496507 [DELETED] 

>>6496398
>As a piddling CS student, I think my best bet may be to go ask a math professor.
It's best to work it out yourself, if you want to know. You've got to feel it. Brute force your way through it if you think you don't have the math to solve it in some more elegant way.

Asking a math profession, might as well just say fuck it and major in communications. You got no drive to learn.

>> No.6496512

>>6496398
>As a piddling CS student, I think my best bet may be to go ask a math professor.
It's best to work it out yourself, if you want to know. You've got to feel it. Brute force your way through it if you think you don't have the math to solve it in some more elegant way.

Asking a math professor, might as well just say fuck it and major in communications. You got no drive to learn.

>> No.6496526
File: 94 KB, 540x1289, 20101024.gif [View same] [iqdb] [saucenao] [google]
6496526

>>6496512