Should I seed a SecureRandom?

I think this is completely unneccessary, because as the Javadoc you quote clearly states: Default-constructed SecureRandom instances seed themselves. The person who wrote this probably didn’t know that. They might also actually decrease security by forcing a fixed seed length that could be less-than-ideal for the RNG implementation. Finally, assuming the snippet is posted unaltered, … Read more

What’s the benefit of seeding a random number generator with only prime numbers?

Well one blink at the implementation would show you that he CAN’T have any reason for that claim at all. Why? Because that’s how the set seed function looks like: synchronized public void setSeed(long seed) { seed = (seed ^ multiplier) & mask; this.seed.set(seed); haveNextNextGaussian = false; } And that’s exactly what’s called from the … Read more

Random number generator that produces a power-law distribution?

This page at Wolfram MathWorld discusses how to get a power-law distribution from a uniform distribution (which is what most random number generators provide). The short answer (derivation at the above link): x = [(x1^(n+1) – x0^(n+1))*y + x0^(n+1)]^(1/(n+1)) where y is a uniform variate, n is the distribution power, x0 and x1 define the … Read more

Generating Random Numbers in Go

Depending on your use case, another option is the math/rand package. Don’t do this if you’re generating numbers that need to be completely unpredictable. It can be helpful if you need to get results that are reproducible, though — just pass in the same seed you passed in the first time. Here’s the classic “seed … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)