I need to do some homework for practising with Matlab but I
I need to do some homework for practising with Matlab but I can\'t figure it out what should I do next
Create a function named generateNormalVars which generates a sequence of pseudo-random numbers from a normal distribution.
The function will accept one, two or three arguments. If the second or third argument is not supplied, the function must use a default value for that argument, as specified below.
Input variables:
 n – The number of pseudo-random values to generate.
 mu – The mean value of the normal distribution from which the values are to be generated.
 This argument is optional, in the sense that the function may be called with fewer than 2 arguments. In the event that a value for this argument is not supplied, you should use a default value of mu = -0.2.
sigma – The standard deviation of the normal distribution from which the values are to be generated.
 This argument is optional, in the sense that the function may be called with fewer than 3 arguments. In the event that a value for this argument is not supplied, you should use a default value of sigma = 2.3.
Notes:
You will be using different default values for mu and sigma, but you should be able to replicate the sequences generated by test1 and test2 manually by seeding the random number generator as in the sample code, then executing your function with 0 and 1 as the second and third arguments respectively.
---------------------------------------------------------------------------------------------------------------------------------------------
function sample = generateNormalVars (n,mu,sigma)
mu = -0.2;
 sigma = 2.3;
so far I have done this..
Solution
Two types of random-number functions are available in SAS. The newest random-number function is the RAND function. It uses the Mersenne-Twister pseudo-random number generator (RNG) that was developed by Matsumoto and Nishimura (1998). This RNG has a very long period of 219937 - 1, and has very good statistical properties. (A period is the number of occurrences before the pseudo-random number sequence repeats.)
The RAND function is started with a single seed. However, the state of the process cannot be captured by a single seed, which means that you cannot stop and restart the generator from its stopping point. Use the STREAMINIT function to produce a sequence of values that begins at the beginning of a stream. For more information, see the Details section of theRAND Function.
The older random-number generators include the UNIFORM, NORMAL, RANUNI, RANNOR, and other functions that begin with RAN. These functions have a period of only 231 - 2 or less. The pseudo-random number stream is started with a single seed, and the state of the process can be captured in a new seed. This means that you can stop and restart the generator from its stopping point by providing the proper seed to the corresponding CALL routines. You can use the random-number functions to produce a sequence of values that begins in the middle of a stream.
Random-number functions and CALL routines generate streams of pseudo-random numbers from an initial starting point, called a seed, that either the user or the computer clock supplies. A seed must be a nonnegative integer with a value less than 231-1 (or 2,147,483,647). If you use a positive seed, you can always replicate the stream of random numbers by using the same DATA step. If you use zero as the seed, the computer clock initializes the stream, and the stream of random numbers cannot be replicated.
Using the DATA Step to Generate a Single Stream of Random Numbers
The DATA steps in this section illustrate several properties of the random-number functions. Each of the DATA steps that call a function generates a single stream of pseudo-random numbers based on a seed value of 7, because that is the first seed for the first call for every step. Some of the DATA steps change the seed value in various ways. Some of the steps have single function calls and others have multiple function calls. None of these DATA steps change the seed. The only seed that is relevant to the function calls is the seed that was used with the first execution of the first random-number function. There is no way t
| Seed Values | 


