How to generate a uniformly random number U(-1,1) in C#? -


i want generate uniformly distributed random number -1 1 using c#, u(-1,1) in math sign. expected result should real number.

user random.nextdouble() , multiply result 2 subtract 1.

the code:

var rand = new random(); var value = rand.nextdouble() * 2 - 1; 

Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -