Strange
-
Nagy Vilmos wrote:
the average of the range 0.0 - 1.0 is 0.25
It looks like it should be 0.5 - what have I missed?
Nagy Vilmos wrote:
Using 0.1 increments, the average of the range 0.0 - 1.0 is 0.25
Well, going off what he said, it should be:
(0 + 0.1 + 0.2 + 0.3 + 0.4 + 0.5 + 0.6 + 0.7 + 0.8 + 0.9 + 1) / 11
Which, of course, is still 0.5 anyway. So yeah. Mind you, I only have highschool statistics under my belt...
Don't forget to rate my post if it helped! ;) "He has no enemies, but is intensely disliked by his friends." "His mother should have thrown him away, and kept the stork." "There's nothing wrong with you that reincarnation won't cure." "He loves nature, in spite of what it did to him."
-
Nagy Vilmos wrote:
Using 0.1 increments, the average of the range 0.0 - 1.0 is 0.25
Well, going off what he said, it should be:
(0 + 0.1 + 0.2 + 0.3 + 0.4 + 0.5 + 0.6 + 0.7 + 0.8 + 0.9 + 1) / 11
Which, of course, is still 0.5 anyway. So yeah. Mind you, I only have highschool statistics under my belt...
Don't forget to rate my post if it helped! ;) "He has no enemies, but is intensely disliked by his friends." "His mother should have thrown him away, and kept the stork." "There's nothing wrong with you that reincarnation won't cure." "He loves nature, in spite of what it did to him."
There are actually 121 combinations - remember you have to have two values for each and each number multiplied by the other.
Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
-
Today I just noticed that generally: power(rand(),2) > rand()*rand() Practically in excel rand() * rand() average is 1/4 rand()^2 average is 1/3 It blows my mind.
EDIT: You got me: http://xkcd.com/356/[^] Just assume for the moment, that the rand() function returns an integer between 0 and 3. For the ^2 trial:
0^2 = 0
1^2 = 1
2^2 = 4
3^2 = 9Which, as I read it, gives me an average of 3.5. Let's try the rand()*rand() trial then?
Note, that under the parameters, order IS important.
0*0 = 0
0*1 = 0
0*2 = 0
0*3 = 0
1*0 = 0
1*1 = 1
1*2 = 2
1*3 = 3
2*0 = 0
2*1 = 2
2*2 = 4
2*3 = 6
3*0 = 0
3*1 = 3
3*2 = 6
3*3 = 9Now, if you average THAT, you get 36/16, or 2.25. (I would make observations on this data, but it's 11:48PM here, and I don't particularly do math too well at this hour of the evening)
Don't forget to rate my post if it helped! ;) "He has no enemies, but is intensely disliked by his friends." "His mother should have thrown him away, and kept the stork." "There's nothing wrong with you that reincarnation won't cure." "He loves nature, in spite of what it did to him."
-
There are actually 121 combinations - remember you have to have two values for each and each number multiplied by the other.
Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
Ah. You made it sound like you were expecting a simple [0 ... 0.1 ... 1] to average to a number other than 0.5. Yes, I cover that point in my response.
Don't forget to rate my post if it helped! ;) "He has no enemies, but is intensely disliked by his friends." "His mother should have thrown him away, and kept the stork." "There's nothing wrong with you that reincarnation won't cure." "He loves nature, in spite of what it did to him."
-
I got it! We're trying to get the sum of the squares of all numbers between 0 and 1. This is somewhat similar to the surface below the x^2 curve between 0 and 1. The surface below a function in math is called an integral The integral of x^2 is x^3/3[^] The surface is therefore (x^3/3) when x = 1 minus (x^3/3) when x = 0 We get 1/3 - 0 = 1/3 I was not after a surface but it's near enough for me.
EUREKA! Ok, if you apply Pascal Ganaye's integration (which I should have thought of from like 4 weeks ago), you can see why the average is 1/3 for the x^2 case. Here's my mathematical steps to showing that rand() * rand() averages to 0.25: rand() * rand() = x * y The integral of x * y (in terms of x) = (y * x^2)/2 Execute the integral from 0 to 1: [(y * x^2)/2]*1 - [(y * x^2)/2]*0 = y/2 Now, we've summed all the different values of x, leaving them in terms of y. Therefore, if we use the average of y (that is, the average of [0 ... 1], which is theoretically 0.5), we can get the average value: 0.5/2 which is....... 0.25! If you don't follow/find an error, I'll fix it LATER in the morning.
Don't forget to rate my post if it helped! ;) "He has no enemies, but is intensely disliked by his friends." "His mother should have thrown him away, and kept the stork." "There's nothing wrong with you that reincarnation won't cure." "He loves nature, in spite of what it did to him."
-
Today I just noticed that generally: power(rand(),2) > rand()*rand() Practically in excel rand() * rand() average is 1/4 rand()^2 average is 1/3 It blows my mind.
Pascal Ganaye wrote:
Practically in excel
rand() * rand() average is 1/4
rand()^2 average is 1/3These stats back up your excel averages. I don't see why a generally higher average value equating to generally being bigger more often blows your mind. However 53.77% (352800/6561) isn't THAT general a rule. If you are seeing a significantly greater than the predicted 7.5% probability, THEN that would be significant. I first used an example given in another thread, ranging from 0 to 1, then realized that isn't close to real random numbers so used a model closer to reality:
static void Main(string\[\] args) { ArrayList Sqrs = new ArrayList(); ArrayList xys = new ArrayList(); double\[\] val = { .1, .2, .3, .4, .5, .6, .7, .8, .9 };//0, ... , 1 int cnt = 0; double sum = 0; foreach (double x in val) { sum += x; cnt++; } Console.WriteLine("Average from 0 to 1 is {0}",sum/cnt); cnt = 0; sum = 0; foreach (double x in val) foreach (double y in val) { sum += x \* y; cnt++; } Console.WriteLine("Average from 0 to 1 x\*y is {0}", sum / cnt); cnt = 0; sum = 0; foreach (double x in val) foreach (double y in val) { sum += x \* x; cnt++; Sqrs.Add(x \* x); xys.Add(x \* y); } Console.WriteLine("Average from 0 to 1 x\*x is {0}", sum / cnt); cnt = 0; int cnt1 = 0; for (int i = 0; i < Sqrs.Count; i++) for (int j = 0; j < Sqrs.Count; j++) { if ((double)Sqrs\[i\] > (double)xys\[j\]) cnt++; else cnt1++; } Console.WriteLine("# where square is larger {0}, else {1}", cnt, cnt1); //Average from 0 to 1 is 0.5 //Average from 0 to 1 x\*y is 0.25 //Average from 0 to 1 x\*x is 0.316666666666667 //# where square is larger 3528, else 3033 Console.Read(); }
-
Today I just noticed that generally: power(rand(),2) > rand()*rand() Practically in excel rand() * rand() average is 1/4 rand()^2 average is 1/3 It blows my mind.
What would be interresting to know is how much times have you tried it before you concluded that it is behaving strange and... Where the heck do you find the time to bother yourself with these things? Were you trying to find a more random number?
Cogito ergo sum
-
What would be interresting to know is how much times have you tried it before you concluded that it is behaving strange and... Where the heck do you find the time to bother yourself with these things? Were you trying to find a more random number?
Cogito ergo sum
Actually, I was working on something really practical. I need to generate random data for a scalability test. I google to get a list of firstname and lastname. Originally I was creating contacts with just a random name.
string firstname = names[(int)(Random.Next()*names.Count)];
But I wanted to generate data that is somewhat realistic. For example to improve realism some firstname should appear more often and we should get duplicates on common names 'john smith'. This is when I came with this :
string firstname = names[(int)(Random.Next()*Random.Next()*names.Count)];
This worked in fact pretty well. I did get much more of the people in the beginning of the list. But I had much fewer instances of the names at the end of the list than expected. You see I did not really seek into this until a bug found me. And this is why I went to the bottom of it.
-
Actually, I was working on something really practical. I need to generate random data for a scalability test. I google to get a list of firstname and lastname. Originally I was creating contacts with just a random name.
string firstname = names[(int)(Random.Next()*names.Count)];
But I wanted to generate data that is somewhat realistic. For example to improve realism some firstname should appear more often and we should get duplicates on common names 'john smith'. This is when I came with this :
string firstname = names[(int)(Random.Next()*Random.Next()*names.Count)];
This worked in fact pretty well. I did get much more of the people in the beginning of the list. But I had much fewer instances of the names at the end of the list than expected. You see I did not really seek into this until a bug found me. And this is why I went to the bottom of it.
Cool, that actually makes sense. I always think it is rather strange that some people spend a whole lot of time on stuff that in reality is insignificant. In your case it really seems that you've done your homework but when the answers don't add up you do have to figure out where something went wrong. Otherwise you might end up with a buggy solution. Good job so far i'd say. Cheers, AT
Cogito ergo sum
-
Today I just noticed that generally: power(rand(),2) > rand()*rand() Practically in excel rand() * rand() average is 1/4 rand()^2 average is 1/3 It blows my mind.
Yup, math is cool.