Yet when I test the top level script with this:
m=5
s=2
n=500
this program then spits out 1000 numbers instead of 500. Why?

Thanks,

Kim

Nov 15th 2008, 01:34 PM

Laurent

Quote:

Originally Posted by Kim Nu

I wrote a function and a top level script that queries and will return n random numbers that are normally distributed with mean m and standard deviation s.

Here is my function and top level script:

Function:

function[gaussian]=my_gaussian(m,s,n);

gaussian=randn(1,n.*s)+m

The problem is on this last line: you're asking for a 1-column and -lines matrix of random numbers.
Whereas what you needed is a 1-column and -lines matrix of random numbers, multiplied by . That is to say:

Code:

gaussian=s*randn(1,n)+m

Nov 16th 2008, 07:07 AM

Kim Nu

Thanks, I thought it was something minor like this. Thanks for all your help.