## Uniform Simulation

Occasional Contributor
Posts: 16

# Uniform Simulation

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)?

Posts: 3,040

## Re: Uniform Simulation

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;

--
Paige Miller
Occasional Contributor
Posts: 16

## Re: Uniform Simulation

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)?

Posts: 3,040

## Re: Uniform Simulation

```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

--
Paige Miller
Occasional Contributor
Posts: 16

## Re: Uniform Simulation

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;

Posts: 3,040

## Re: Uniform Simulation

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

--
Paige Miller
SAS Super FREQ
Posts: 4,242

## Re: Uniform Simulation

Discussion stats
• 6 replies
• 379 views
• 0 likes
• 3 in conversation