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

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -