Skip to main content
1-Visitor
Oct 5, 2014 7:22 PM UTC
Solved

rnd (-1,+1)?

Hello,

How can I use "rnd" function to generate random numbers between [-1,1] rather than [0,1] ?

Thank you.

Werner_E
Werner_EAnswer
25-Diamond I
Oct 5, 2014 7:38 PM UTC

rnd(2) -1

You may use a selfdefined function rand(a,b):=a + rnd(b-a)

If you need a vector of more values you may use runif(100,-1,1)

2 replies

Werner_E
Werner_E25-Diamond IAnswer
25-Diamond I
Oct 5, 2014 7:38 PM UTC

rnd(2) -1

You may use a selfdefined function rand(a,b):=a + rnd(b-a)

If you need a vector of more values you may use runif(100,-1,1)

Translate
payman1-VisitorAuthor
1-Visitor
Oct 5, 2014 7:52 PM UTC

Thank you.

Translate