REAL random numbers?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
infinte
Prole
Posts: 18
Joined: Wed Sep 21, 2011 9:31 am

REAL random numbers?

Post by infinte »

Using CryptGenRandom or /dev/random?
Maybe a mixed implementation between real and pesudo.
User avatar
rude
Administrator
Posts: 1052
Joined: Mon Feb 04, 2008 3:58 pm
Location: Oslo, Norway

Re: REAL random numbers?

Post by rude »

User avatar
Taehl
Dreaming in associative arrays
Posts: 1025
Joined: Mon Jan 11, 2010 5:07 am
Location: CA, USA
Contact:

Re: REAL random numbers?

Post by Taehl »

/dev/random isn't quite as good as many people think... And CryptGenRandom is only pseudorandom (very good pseudorandom, yes, but still not true random).

What do you need true random numbers for, anyway?
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
User avatar
vrld
Party member
Posts: 917
Joined: Sun Apr 04, 2010 9:14 pm
Location: Germany
Contact:

Re: REAL random numbers?

Post by vrld »

On Linux, /dev/random should generate random bits by using the user input and other external sources, so there should be no underlying computation method to get these bits. But: Depending on how you interpret these bits, you can get different random distributions other than the uniform distribution (each number is equally likely to be drawn), meaning that some numbers are more likely to occur than others. The numbers are still "really" random though.

So, what do you mean by "real" random numbers? Numbers that are drawn from a uniform distribution with no underlying computation scheme?

BTW: Randomness often defies intuition. Watch this:
I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum.

hump | HC | SUIT | moonshine
User avatar
adnzzzzZ
Party member
Posts: 305
Joined: Sun Dec 26, 2010 11:04 pm
Location: Porto Alegre, Brazil

Re: REAL random numbers?

Post by adnzzzzZ »

 
Last edited by adnzzzzZ on Tue Oct 10, 2017 6:30 pm, edited 1 time in total.
User avatar
Taehl
Dreaming in associative arrays
Posts: 1025
Joined: Mon Jan 11, 2010 5:07 am
Location: CA, USA
Contact:

Re: REAL random numbers?

Post by Taehl »

vrld wrote:So, what do you mean by "real" random numbers?
Real random numbers depend on having sufficient entropy to make bits out of. /dev/random pulls entropy from sources like tiny system temperature and voltage fluctuations and CPU usage at various points in time, which is a great idea. However, patterns sometimes show up even in inputs like those, meaning the pool is getting less entropy than /dev/random assumes it is.

Don't get me wrong, /dev/random is probably the highest-quality randomness you can get without specialized hardware. But I, personally, wouldn't want to trust it 100% completely.
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: REAL random numbers?

Post by bartbes »

True randomness can't be generated.
Disprove me, if it is influenced by anything (which it should if it doesn't wants to be a calculation), it is by definition something that can be influenced, meaning it's not truely random. At some point you just have to give in ;).
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: REAL random numbers?

Post by kikito »

Sure.

Image
(source)

:ultrahappy:

Now seriously - as Bartbes says, generating really random numbers isn't very practical on your average computer.

Is there a reason why the "standard" approach isn't good enough for you? I mean this one:

Code: Select all

function love.load()
  math.randomseed( os.time() ) -- you call this once at the begining of your program
end

function love.update()
  ...
  local myRandomNumber = math.random()
  ...
end
Maybe if you tell us why it isn't enough for you, we can help you find a solution that, while not purely random, is good enough for you.
When I write def I mean function.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 3 guests