Um... is this new?

For questions about using Classic.

Post » Tue Sep 29, 2009 9:02 pm

Check under the system expressions for math you'll find this:
Normal distribution random
Pretty sure I haven't seen that one before.

So what exactly is its usage, I mean besides a random generator. I get mean, but sigma???

NormalRandom(mean, sigma)
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Tue Sep 29, 2009 11:13 pm

Stolen pic from wikipedia:

click for image (didn't embed properly)

Basically, it generates a random number with that kind of distribution. mean = peak, sigma is proportional to the width of the bell shape, and numbers are more likely to be generated where the graph is higher. Note it goes off infinitely in either direction so in theory it could generate any number no matter the mean and sigma, but most of those values would be nigh on impossible. You can always clamp the output for a certain range.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Tue Sep 29, 2009 11:26 pm

Can I get an example, cause as usual I'm doing it wrong.

System: Always (every tick)
> SystemCreate object Sprite 0 on layer 1 at (NormalRandom(300, 100), NormalRandom(200, 50))
> TextSet text to NormalRandom(300, 100)
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Thu Aug 19, 2010 1:16 pm

This might be useful, despite thread necromancy from 2008.


Sigma is the Standard Deviation for a Normal curve. For any given normal curve (shown in that linked picture above) there is a standard deviation where ~34% either side of the mean (peak) will fall.
There's a great picture on the wikipedia page:
[url:2xpqpmdh]http://en.wikipedia.org/wiki/Normal_distribution#Standardizing_normal_random_variables[/url:2xpqpmdh].

Normal random vs ... typical random.
If you drew a normal random from 100, you are equally as likely to get 2 or 98 (each is 1/100 chance) as you are to get 45, 50, 60, 73 etc. With a normal curve, the further you are from the mean (50), the lower the chance of that number appearing. So, 2 or 98 will occur very infrequently (~1%) and most results will land around the 50 mark. If your sigma is larger, then the curve is flatter and in the 1-100 example, there will be a greater chance to get numbers between 30 and 70.

This is a really cool feature, although I haven't actually found a use for it yet.
B
2
G
2
Posts: 42
Reputation: 734

Post » Thu Aug 19, 2010 9:59 pm

Actually since your output can range from positive to negative, unlike the regular random, I found its quite useful for generating a random sinus curve.
With that you can make a ai type movement that is limited to a set of certain x, or y coords on the screen without using clamp.
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Wed Jun 05, 2013 2:07 pm

Perhaps I'm missing something, but I cannot find the command NormalRandom anywhere. Is it out of the program perhaps?
B
18
S
2
Posts: 7
Reputation: 910

Post » Wed Jun 05, 2013 3:55 pm

@guardofdarkness

Are you using Construct Classic?
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests