Jump to content




Random Number API (more random than math.random()!)


4 replies to this topic

#1 Jappards

  • Validating
  • 116 posts
  • LocationHolland

Posted 08 July 2013 - 10:55 AM

when i looked at the math library tutorial, i was shocked of the effectiveness of math.random(), because math.random() is pseudo random, not truly random, ok, this API isn`t truly random either, but it`s very close to it,so i began to improve the PRNG (pseudo-random number generator) and this is the result.

features:
Spoiler

code:
http://pastebin.com/nZAfgJVk

usage:
1.pastebin get nZAfgJVk RandomNumber
2.os.loadAPI("RandomNumber")
3.????
4.PROFIT!!!

#2 Lymia Aluysia

  • Members
  • 31 posts
  • LocationHer own imagination~

Posted 08 July 2013 - 01:03 PM

http://pastebin.com/8YKL5g7j

Posted Image
This is an... interesting, ah, "concept"...

#3 Oddstr13

  • Members
  • 25 posts
  • LocationNorway

Posted 08 July 2013 - 01:09 PM

I am sorry that i wasn't able to get this thru to you on IRC.

The number returned by math.random() isn't 0 or 1, it is a decimal number between 0.0 and 1.0 with several decimal places.
Let's try multiplying that number with 10^7.

We now suddenly have a number between 0 and 10000000, that is, zero and ten millions.
And we might still have a few decimals left.

Besides that fact, this is what happened when i tested your code;
your api is saved as rnd, then loaded with os.loadAPI("rnd")
Posted Image

As you can see, genNumber() is far from random, and genBetween() dosn't exactly return what i would expect.



Best Regards
Oddstr13

#4 Mikeemoo

  • Members
  • 732 posts
  • LocationLondon, UK

Posted 08 July 2013 - 01:26 PM

lol

#5 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 08 July 2013 - 02:00 PM

This is both useless and misleading. It is also less random than unseeded math.random.

Just use math.random.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users