Jump to content

Recommended Posts

Posted

hey ya'll.

Is math.random broken somehow?

if I use math.random(1,5) I get a value >1 all the time.

I've also had it giving me very predictable results, even more so than usual for lua.

 

I was gonna have two groups do different things, so I'm calling it like

 

group1thing = math.random(1,5)

group2thing = math.random(1,5)

 

even with multiple iterations, they always do the same thing...

Posted

Here is the distribution for 1000 checks. 1 and 5 do occur less frequently than others values and that behavior was repeated over several checks. So statistically 1 should occur 20% of the time, in reality it is around 12% of the time. I'll have to check older versions to see if that behavior has changed, but I don't know if it has.

 

1: 127

2: 235

3: 267

4: 246

5: 125

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Posted

Thanks Grimes.

So you get a bell curve, Rodger.

But I still have the other problem (which I probably didn't draw enough attention to)

I always get a result <1, usually like .1257657 regardless of what inputs I use.

Posted

I have noticed also that math.random appeared to return numbers heavily skewed towards a non-random result. Been wondering about the validity of the random.seed, but that would not account for the bell curve result.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...