random - is there any drand48() equivalent in python or a wrapper to it? -


I am converting some code to Python. I'm thinking that dragon 48 () is equivalent to a dragon (exactly the same!) Or a cover?

Thank you very much

you random.random .

  gt; & Gt; & Gt; Import Random & gt; & Gt; & Gt; Help (random)> gt; & Gt; & Gt; Random.random () 0.8423026866867628   

This does not use the same generator as the drand48 . drand48 The family uses 48-bit linear congurential generators, while the Python random module uses the better Merson Twister algorithm.

If you want accurate as output drand48 , you can implement it in Python.

  Delete the next line while using # Python 2.x ... # __future__ # Rand48 (object) from the import division category: def __init __ (self, seed): self. N = seed DEF seeds (self, seed): self N = seed DRF source (self, seed): self N = (Beed and LT; <16) + 0x330e def next (self): self.n = (25214903917 * self.n + 11) & amp; (2 ** 48 - 1) Refund yourself. NF Drunk (self): Returns self. Nxt () / 2 ** 48 df lend (self): returns self Nxt ()> & Gt; 17 DR gang (self): n = self. () & Gt; & Gt; 16 if n & amp; (1 <31): n - = 1 & lt; & Lt; 32 returns n   

However, the output will be significantly lower than the standard random number generator of Python. The family of the rand48 function was declared in 1989 by the SVID 3 as obsolete.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -