Flash Flash Revolution

Flash Flash Revolution (http://www.flashflashrevolution.com/vbz/index.php)
-   Homework & Help (http://www.flashflashrevolution.com/vbz/forumdisplay.php?f=68)
-   -   Math Question - Probability (http://www.flashflashrevolution.com/vbz/showthread.php?t=147964)

TheSaxRunner05 07-26-2017 01:38 PM

Math Question - Probability
 
Let's say you had a number line with all real numbers between 1 and 5. If you were to randomly select a bunch of numbers within this range, the average result would become closer to three the larger the sample size became. So the expected value of this scenario is 3.

My question though, is what if you take N random numbers generated and keep the best result? What is the relationship between N and the expected maximum result within the list of outputs?

Dinglesberry 07-26-2017 01:43 PM

Re: Math Question - Probability
 
N/2

EDIT: i think it might be π

TheSaxRunner05 07-26-2017 01:48 PM

Re: Math Question - Probability
 
Quote:

Originally Posted by Dinglesberry (Post 4573622)
N/2

EDIT: i think it might be π

If it was N, I'd have an expected max value of 6 after 6 rolls, but no single result
can go over 5

TheSaxRunner05 07-26-2017 01:53 PM

Re: Math Question - Probability
 
I'm not quite sure how to get there, but my intuition is that if you graphed the answer, it would have a horizontal asymptote at y=5

inDheart 07-26-2017 02:06 PM

Re: Math Question - Probability
 
what is the "best" result?

TheSaxRunner05 07-26-2017 02:11 PM

Re: Math Question - Probability
 
Quote:

Originally Posted by inDheart (Post 4573630)
what is the "best" result?

Sorry that isn't very mathy lol

Later I spell it out a bit better, saying the expected maximum value, I mean the expected maximum number from the pool of N random real numbers between 1 and 5. So if you picked 100 random real numbers between 1 and 5, how close to 5 is the expected maximum value? How do I find an equation for the maximum expected value for N random numbers.

SKG_Scintill 07-26-2017 02:23 PM

Re: Math Question - Probability
 
just tried it empirically with some quick code

Code:

$array = array();
for ($i = 0; $i < 1000; $i++) {
        $highest = 0;
        for ($j = 0; $j < 100; $j++) {
                $rand = mt_rand(1,5);
                if ($rand > $highest) {
                        $highest = $rand;
                }
        }
        array_push($array, $highest);
}
$sum = 0;
foreach ($array as $num) {
        $sum += $num;
}
echo $sum / sizeof($array);


the $j < [num] is the amount of numbers I take before I take the best result
here's the result for different amounts
1: 3.089
2: 3.811
3: 4.162
4: 4.436
5: 4.577
10: 4.892
100: 5

so yes, it goes to 5

doesn't give a mathematical relationship but whatever I was bored

TheSaxRunner05 07-26-2017 02:34 PM

Re: Math Question - Probability
 
I found something close -
Y = nth root(.5) * (Maximum value)

Does this seem correct? It has a max value of 5, but N=2 gives 3.53

Edit:// If you pick two numbers, you're asking, at what value are the product of these two probabilities 50%? So having two probabilities of sqrt .5 (.7071...) multiplied together gives probability .5. The same would go for 3, 4, 5, or N numbers.

Is this reasoning sound?

TheSaxRunner05 07-26-2017 02:55 PM

Re: Math Question - Probability
 
I edited my old post to hell, so I'm making a new post. My previous error was including the minimum and maximum value in the formula.

MarcusHawkins 07-26-2017 03:40 PM

Re: Math Question - Probability
 
Simple.

(Max Value + Min Value) / 2

Of course, you can also create (Min Value + Max Value) / 2 and receive the same result.

EDIT: I think I misread your question, and I apologize.

HOWEVER, this is good for finding the average of all possible numbers from your lowest to highest amount, whatever that may be.

TheSaxRunner05 07-26-2017 03:48 PM

Re: Math Question - Probability
 
Quote:

Originally Posted by MarcusHawkins (Post 4573642)
Simple.

(Max Value + Min Value) / 2

Of course, you can also create (Min Value + Max Value) / 2 and receive the same result.

I don't think you quite get what I'm asking, see my later posts in the thread to see what I mean.

I think I figured it out though.

SKG_Scintill 07-26-2017 04:04 PM

Re: Math Question - Probability
 
I'm breaking my head lmao

so I may be going completely in the wrong direction
this *should* be the average of your situation

you can see the way it expands for every extra random number you take before you take the highest one
I can't get that expansion written as a product summation
but fk man I only did high school math

fun tho
would like to see someone else just go, you know, the easy route

ilikexd 07-26-2017 04:16 PM

Re: Math Question - Probability
 
The EV of the highest number of N terms between 1 and 5 is the EV of the highest number of N-1 terms + 3/(2^N)

So when you start with 1 term between 1 and 5, you start with 3/(2^0)=3
3+3/(2^1)=4.5
4.5+3/(2^2)=5.25
etc.

Oh never mind, that's just wrong. :( I need to adjust the numbers.

e: This ends up being the answer for numbers between 0 and 6 though.

ilikexd 07-26-2017 04:24 PM

Re: Math Question - Probability
 
It should be the EV of the highest number among N terms is the highest number among N-1 terms + 3.2/(2^N). It doesn't apply to the first term though, which is just 3.

3+3.2/(2^2)
3+3.2/4=3.8

3.8+3.2/(2^4)
3.8+3.2/8=4.2

etc.

It should asymptotically approach 5 too.

SKG_Scintill 07-26-2017 04:54 PM

Re: Math Question - Probability
 
got it down to this

k is the highest number you go to (from 1 to "5")
m is the amount of times you take a random number before taking the highest number

...now I gotta think...

edit: darn nathan is that it? :P
edit v2: mine works for the first term
edit v3: looking at yours nathan, I think that's one of the first things that got me troubled, because that approach stops working from 4 and onward I believe

TheSaxRunner05 07-26-2017 04:59 PM

Re: Math Question - Probability
 
Quote:

Originally Posted by ilikexd (Post 4573650)
It should be the EV of the highest number among N terms is the highest number among N-1 terms + 3.2/(2^N). It doesn't apply to the first term though, which is just 3.

3+3.2/(2^2)
3+3.2/4=3.8

3.8+3.2/(2^4)
3.8+3.2/8=4.2

etc.

It should asymptotically approach 5 too.

May I ask where the 3.2 constant comes from? I'm a little confused where that number comes from.

ilikexd 07-26-2017 05:05 PM

Re: Math Question - Probability
 
Quote:

Originally Posted by SKG_Scintill (Post 4573657)
edit v3: looking at yours nathan, I think that's one of the first things that got me troubled, because that approach stops working from 4 and onward I believe

that's a shame, i had bruteforced 3, 3.8, and 4.2 as the answers for n=1,2,3 with very long arithmetic and assumed a relation there

why don't you just run your program a bunch of times and take the average results so an equation can be fitted to them?

TheSaxRunner05 07-26-2017 05:13 PM

Re: Math Question - Probability
 
Here's my line of thinking: The probability of a single random number being above or below 3 is 50%. There is 50% of the range on the left and 50% of the range to the right.

It gets more complicated when you add a second probability. I'm looking for the product of two numbers that equals .5, so I take the sqr root of .5 - or .707

This number means the highest of two individual random numbers has a 50% chance of being in the top 29.3% percentile of all possible random numbers. If I take the .707 and multiply by 5, the max value, I get ~3.535 for an expected value.

For three numbers, I'm asking what three probabilities multiplied together reach 50% probability. The cubic root of .5 is .793, multiplied by 5 is ~3.968.

If this line if reasoning is incorrect, it would be helpful to me to know where the logical flaw lies, so I better understand it.

SKG_Scintill 07-26-2017 05:47 PM

Re: Math Question - Probability
 
@Nathan: I made a code that does my formula to give you the average number instead
using 1 to 5, up to 10 times before taking the highest number
Code:

<?php

for ($m = 1; $m <= 10; $m++) {
        $res = 0;
        for ($n = 1; $n <= 5; $n++) {
                $part = $n * (pow($n,$m) - pow($n-1,$m));
                $res += $part;
        }
        $avg = $res / pow(5, $m);
        echo $avg . '<br/>';
}


here are the results:
3
3.8
4.2
4.4336
4.584
4.68704
4.76064
4.81477376
4.85544192
4.88647424

edit: tried to use wolframalpha to see what it could do with my formula, but it's giving me some harmonic number series, which I know nothing of :|
here's the formula I know nothing of

k, n and m being variables, H being... something mathematical

edit v2: for now I'll keep it at this formula, reposting it so I can at least sleep
k is highest number (1 to "5")
n is current number in summation
m is amount of times before taking highest number
average =

SKG_Scintill 07-26-2017 08:01 PM

Re: Math Question - Probability
 
heh in my formula's case 0^0 = 1

TheSaxRunner05 07-26-2017 08:20 PM

Re: Math Question - Probability
 
Quote:

Originally Posted by SKG_Scintill (Post 4573727)
heh in my formula's case 0^0 = 1

Makes sense heh

I think I found the problem with my formula -
My Nth root of .5 * 5 formula only works for picking values 0 - 5, I don't know how to factor in starting at 1. What it's multiplied by determines the asymptote and I can't Add a constant, or the result will go over 5.

Edit:// Ok I was close

I think it's (xth-root of .5)*4 +1

SKG_Scintill 07-26-2017 08:42 PM

Re: Math Question - Probability
 
that doesn't work

using 1 to 5, doing it twice before taking highest
Code:

[num1, num2]: highestnum
1,1: 1        2,1: 2        3,1: 3        4,1: 4        5,1: 5
1,2: 2        2,2: 2        3,2: 3        4,2: 4        5,2: 5
1,3: 3        2,3: 3        3,3: 3        4,3: 4        5,3: 5
1,4: 4        2,4: 4        3,4: 4        4,4: 4        5,4: 5
1,5: 5        2,5: 5        3,5: 5        4,5: 5        5,5: 5

[amount of combinations]
5^2 = 25

[number's amount of occurrences]
1: 1
2: 3
3: 5
4: 7
5: 9

[weight of numbers]
1: 1 * 1 = 1
2: 3 * 2 = 6
3: 5 * 3 = 15
4: 7 * 4 = 28
5: 9 * 5 = 45

[sum of weights]
1 + 6 + 15 + 28 + 45 = 95

[average] = [sum of weights] / [amount of combinations]


average: 95 / 25 = 3.8

using your formula:
0.5^(1/2)*4+1 = 3.8284~~~

TheSaxRunner05 07-26-2017 09:03 PM

Re: Math Question - Probability
 
Quote:

Originally Posted by SKG_Scintill (Post 4573738)
that doesn't work

using 1 to 5, doing it twice before taking highest
Code:

[num1, num2]: highestnum
1,1: 1        2,1: 2        3,1: 3        4,1: 4        5,1: 5
1,2: 2        2,2: 2        3,2: 3        4,2: 4        5,2: 5
1,3: 3        2,3: 3        3,3: 3        4,3: 4        5,3: 5
1,4: 4        2,4: 4        3,4: 4        4,4: 4        5,4: 5
1,5: 5        2,5: 5        3,5: 5        4,5: 5        5,5: 5

[amount of combinations]
5^2 = 25

[number's amount of occurrences]
1: 1
2: 3
3: 5
4: 7
5: 9

[weight of numbers]
1: 1 * 1 = 1
2: 3 * 2 = 6
3: 5 * 3 = 15
4: 7 * 4 = 28
5: 9 * 5 = 45

[sum of weights]
1 + 6 + 15 + 28 + 45 = 95

[average] = [sum of weights] / [amount of combinations]


average: 95 / 25 = 3.8

using your formula:
0.5^(1/2)*4+1 = 3.8284~~~

I see, and since all answers will be rational numbers, using the square root function will fail. I can match one really close to the actual probabilities, but really close is like horseshoes and hand grenades in math lol

Thanks for going back and forth on this, I'm going to toy with the equation you posted a bit more.

reuben_tate 07-26-2017 09:12 PM

Re: Math Question - Probability
 
I came up with this: http://puu.sh/wU5Jx/8ad6c883ab.pdf

Got the equation (5n+1)/(n+1)

If there's any errors or questions about my work, let me know. Or if someone finds a more elegant solution, I'd also be up for seeing it.

EDIT: Here's a graph

MarcusHawkins 07-26-2017 09:19 PM

Re: Math Question - Probability
 
Quote:

Originally Posted by reuben_tate (Post 4573744)
I came up with this: http://puu.sh/wU5Jx/8ad6c883ab.pdf

Got the equation (5n+1)/(n+1)

If there's any errors or questions about my work, let me know. Or if someone finds a more elegant solution, I'd also be up for seeing it.

EDIT: Here's a graph

Oh, so the formula is essentially (Max value*n + Min value)/(n + Min value), if I'm understanding this right?

TheSaxRunner05 07-26-2017 09:25 PM

Re: Math Question - Probability
 
Quote:

Originally Posted by reuben_tate (Post 4573744)
Got the equation (5n+1)/(n+1)

Plugging 2 into this equation gives 11/3 or 3.666....

Is there an error in what Scintill showed earlier to show an answer of exactly 3.8?

Quote:

Originally Posted by SKG_Scintill (Post 4573738)
that doesn't work

using 1 to 5, doing it twice before taking highest
Code:

[num1, num2]: highestnum
1,1: 1        2,1: 2        3,1: 3        4,1: 4        5,1: 5
1,2: 2        2,2: 2        3,2: 3        4,2: 4        5,2: 5
1,3: 3        2,3: 3        3,3: 3        4,3: 4        5,3: 5
1,4: 4        2,4: 4        3,4: 4        4,4: 4        5,4: 5
1,5: 5        2,5: 5        3,5: 5        4,5: 5        5,5: 5

[amount of combinations]
5^2 = 25

[number's amount of occurrences]
1: 1
2: 3
3: 5
4: 7
5: 9

[weight of numbers]
1: 1 * 1 = 1
2: 3 * 2 = 6
3: 5 * 3 = 15
4: 7 * 4 = 28
5: 9 * 5 = 45

[sum of weights]
1 + 6 + 15 + 28 + 45 = 95

[average] = [sum of weights] / [amount of combinations]


average: 95 / 25 = 3.8

using your formula:
0.5^(1/2)*4+1 = 3.8284~~~


reuben_tate 07-26-2017 09:30 PM

Re: Math Question - Probability
 
Quote:

Originally Posted by TheSaxRunner05 (Post 4573752)
Plugging 2 into this equation gives 11/3 or 3.666....

Is there an error in what Scintill showed earlier to show an answer of exactly 3.8?

It looks like that is the case if you're looking at the discrete probability (the only options are 1, 2, 3, 4, 5) as opposed to the continuous probability (you can pick any real number between 1 and 5). So I'd expect it to be close but not exactly the same.

reuben_tate 07-26-2017 09:31 PM

Re: Math Question - Probability
 
Quote:

Originally Posted by MarcusHawkins (Post 4573750)
Oh, so the formula is essentially (Max value*n + Min value)/(n + Min value), if I'm understanding this right?

It seems that might be the case...wolframalpha won't do the integral in the general case for me...so I'll have to compute it by hand. I can double check.

TheSaxRunner05 07-26-2017 09:33 PM

Re: Math Question - Probability
 
Quote:

Originally Posted by MarcusHawkins (Post 4573750)
Oh, so the formula is essentially (Max value*n + Min value)/(n + Min value), if I'm understanding this right?

Sorry if I mistook what you said earlier, I thought you were essentially recapping what I said in my first paragraph of the OP, but you were much more on the right track than I was.

TheSaxRunner05 07-26-2017 09:35 PM

Re: Math Question - Probability
 
Quote:

Originally Posted by reuben_tate (Post 4573756)
It looks like that is the case if you're looking at the discrete probability (the only options are 1, 2, 3, 4, 5) as opposed to the continuous probability (you can pick any real number between 1 and 5). So I'd expect it to be close but not exactly the same.

Gotcha, thanks for the explanation.
I really need to take a calculus course sometime to better understand integrals

MarcusHawkins 07-26-2017 09:47 PM

Re: Math Question - Probability
 
Quote:

Originally Posted by TheSaxRunner05 (Post 4573759)
Sorry if I mistook what you said earlier, I thought you were essentially recapping what I said in my first paragraph of the OP, but you were much more on the right track than I was.

No, you did not mistake what you said earlier, I was indeed taking what you said in the OP before I realized what was going on later on in the thread!

BUT, I KNEW there is a connection somehow, and thanks to ben's formula, I think I found it! I hope he double checks to make sure I'm right, and if not, I'm sure he'll think of something more solid! :P

Thanks nonetheless!

EDIT: I JUST started taking AP Calculus AB, (essentially first year college calculus in high school) and I am learning how to use limits correctly and master that skill.
After THAT, I will be learning how to use integrals correctly, so it should be fun!

SKG_Scintill 07-26-2017 09:49 PM

Re: Math Question - Probability
 
graphs are cute

for 1-5

for 1-k


courtesy of wolframalpha, wonderful site

edit: by the way, are we just neglecting my formula because it isn't elegant enough? :P
edit v2: rewrote it this way, is it elegant enough?

reuben_tate 07-26-2017 10:09 PM

Re: Math Question - Probability
 
Quote:

Originally Posted by MarcusHawkins (Post 4573763)
No, you did not mistake what you said earlier, I was indeed taking what you said in the OP before I realized what was going on later on in the thread!

BUT, I KNEW there is a connection somehow, and thanks to ben's formula, I think I found it! I hope he double checks to make sure I'm right, and if not, I'm sure he'll think of something more solid! :P

Thanks nonetheless!

EDIT: I JUST started taking AP Calculus AB, (essentially first year college calculus in high school) and I am learning how to use limits correctly and master that skill.
After THAT, I will be learning how to use integrals correctly, so it should be fun!

So I let m be the minimum value and M be the maximum value. Here's the updated calculations taking that into account: http://puu.sh/wU7Se/8517d7e64e.pdf

The formula isn't quite as nice...at least it doesn't look like it simplifies to what we thought it might be:


EDIT: Made it a tad bit nicer:

reuben_tate 07-26-2017 10:10 PM

Re: Math Question - Probability
 
Quote:

Originally Posted by SKG_Scintill (Post 4573764)
graphs are cute

for 1-5

for 1-k


courtesy of wolframalpha, wonderful site

edit: by the way, are we just neglecting my formula because it isn't elegant enough? :P
edit v2: rewrote it this way, is it elegant enough?

That rewrite looks a lot nicer :)
Like I said before, I didn't mean to neglect your formula...I'm just trying to solve the "continuous" case instead of the discrete case :P

reuben_tate 07-26-2017 10:26 PM

Re: Math Question - Probability
 
Quote:

Originally Posted by MarcusHawkins (Post 4573763)

EDIT: I JUST started taking AP Calculus AB, (essentially first year college calculus in high school) and I am learning how to use limits correctly and master that skill.
After THAT, I will be learning how to use integrals correctly, so it should be fun!

Nice :) The stuff in the link I put is still a bit beyond the scope of most single-variable Calculus courses. If you want to know more how to do the kind of work in the link, you can peruse an introductory calculus-based probability/statistics book after you feel comfortable with basis derivatives and integrals :)

SKG_Scintill 07-27-2017 10:22 AM

Re: Math Question - Probability
 
as a bit of visualization for my approach

in case I: you take a number from 1-5 twice, so I put the 2 numbers as seperate axes
the squares show how many times the number is the highest
you can see that the occurrences of number N are N squared minus (N-1) squared
aka: n^2 - (n-1)^2

same in case III where I put it as 3 axes and the occurrences of N are N cubed minus (N-1) cubed
aka: n^3 - (n-1)^3

case II is where I multiplied the occurrences of case I by the weight of the number
obviously I can't visualize the same for case III as it would be a 4d shape

at this point I've done n(n^2-(n-1)^2) for case II
so I did a summation for all the numbers N to get the sum of all amounts
with that sum I now have to divide it by the amount of combinations, which is just the size of case I
I tried "re-ordering the blocks" so they'd fit neatly inside eachother, but that doesn't seem to have a simple way (pretty obvious since the averages are decimal numbers)

for the latest rewritten formula I approached it like this:
take case I, make it one dimension greater, so it's [the highest number]^3, then subtract the sum of the smaller numbers squared (*1 to make it little cubes, but that's redundant)

so... summarized
average is ( [the highest number] to the power of ([amount of times you take a number] + 1) minus the sum of [all smaller numbers] to the power of [amount of times you take a number] ) divided by [the highest number] to the power of [amount of times you take a number]
average = ( [k] ^ ([m]+1) - sigma [from n=0 to n = k-1] of n ^ [m]) / k^m
also to be written as

...

no idea if that helps, just having fun
you can see my steps, maybe go a different route


All times are GMT -5. The time now is 12:06 AM.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright FlashFlashRevolution