Hi, if I want to generate a series of random number which is only draw from a given interval, e.g. random number from interval [-1,1]. How should I write in the program code?
Another question is, if I only want to draw some fixed number randomly, example I only want to draw a number from 2 fixed numbers i.e. -1 and 1 randomly, how should I write in my program code?
Generate random number from fixed interval
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Generate random number from fixed interval
Code: Select all
series rand1 = 2*@rnd-1
Code: Select all
series rand2 = @rnd>0.5
rand2 = rand2*1 + (1-rand2)*(-1)
Re: Generate random number from fixed interval
Ok, I got it.
Thank you very much.
Thank you very much.
Who is online
Users browsing this forum: No registered users and 2 guests
