Discussions about Coding and Scripting
Barbie
Godlike
Posts: 2923 Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing
Post
by Barbie » Tue Jan 02, 2024 12:02 pm
Is FRand() + FRand() + FRand() + FRand()
statistically the same as 4 * FRand()
?
"If Origin not in center it be not in center." --Buggie
Buggie
Godlike
Posts: 3164 Joined: Sat Mar 21, 2020 5:32 am
Post
by Buggie » Tue Jan 02, 2024 1:21 pm
No, it is not.
4 random value is not same as one value increased in 4 times.
One value increase in 4 times keep all parameters increased in 4 times.
Sum of 4 value use different params.
For illustrate this, let's replace 4 with some big number like 100 000.
Sum of 100 000 random values very likely be 100 000 times of median for this random value.
When 100 000 multiplied on single random value still be random value, uniformly distributed in some range.
OFC for smaller N it less noticeable and for N = 1 effect is gone.
Barbie
Godlike
Posts: 2923 Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing
Post
by Barbie » Tue Jan 02, 2024 3:16 pm
Thanks. I stumbled over that in class ThingFactory:
Code: Select all
else //timeDistribution is gaussian
nextTime = 0.5 * (FRand() + FRand() + FRand() + FRand()) * interval;
what tries to approximate
exp(-x²)
.
"If Origin not in center it be not in center." --Buggie
_21
Experienced
Posts: 81 Joined: Mon Aug 30, 2021 10:51 am
Post
by _21 » Tue Jan 02, 2024 3:51 pm
At N=4 the distribution is quite similar to a Gaussian, for a video game its a practical technique.
Buggie
Godlike
Posts: 3164 Joined: Sat Mar 21, 2020 5:32 am
Post
by Buggie » Tue Jan 02, 2024 3:59 pm
I found this for 3:
https://www.researchgate.net/figure/Irw ... _319887464
Irwin-Hall-distribution-with-n3-and-the-matching-normal-distribution-with-mean-3-2-and.jpg
Irwin-Hall distribution with n=3 and the matching normal distribution with mean 3/2 and variance 1/4.
Auto merged new post submitted 6 minutes later According to wiki - best use sum of 12 values minus 6:
https://en.wikipedia.org/wiki/Irwin%E2% ... stribution Auto merged new post submitted 1 hour 18 minutes later Also original formula is more like as Bates ditrubution:
https://en.wikipedia.org/wiki/Bates_distribution
(X + X + X + X) / 4 * (2 * Interval).
You do not have the required permissions to view the files attached to this post.