Skip to main content
1-Visitor
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

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

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

Thank you.

Translate