turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- General Programming
- /
- Uniform Simulation

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-04-2013 08:08 AM

Hello,

I need to know the syntax if I need to simulate a vector (5X1) from a continuous distribution with a range from (-3,3)?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Yasmine

11-04-2013 08:34 AM

A vector? Do you mean using PROC IML?

If so, then the UNIFORM function will produce uniform random variables between 0 and 1, see the following the example at SAS/IML(R) 12.3 User's Guide. Thus this slight modification produces uniform random variables between –3 and 3

proc iml;

seed = 123456;

c = j(5, 1, seed); /* generate 5 numbers from the same seed */

b = uniform(c)#6 - 3;

print b;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Yasmine

11-04-2013 08:49 AM

thus you mean by the above that now I will output 5 random numbers from continuous uniform distribution between (-3,3) using sas proc iml?

if I need to output from continuous uniform (-1,1)?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Yasmine

11-04-2013 09:16 AM

thus you mean by the above that now I will output 5 random numbers from continuous uniform distribution between (-3,3) using sas proc iml?

Did you try this code? What happens when you try it?

if I need to output from continuous uniform (-1,1)?

You would modify the example above to produce the range –1 to 1

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to PaigeMiller

11-04-2013 02:48 PM

yes, it gave ranges from -3 to 3

so now if I needed it from -1 to 1, so I will modify the syntax as mentioned below, correct or not?

proc iml;

seed = 123456;

c = j(5, 1, seed); /* generate 5 numbers from the same seed */

b = uniform(c)#2 - 1;

print b;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Yasmine

11-04-2013 03:26 PM

Looks good to me! But don't take my word, run the code and see what you get

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Yasmine

11-08-2013 03:07 PM

See this article: How to generate random numbers in SAS - The DO Loop