From: Kitty Huang on 29 Jan 2010 00:27 Hi, I am new for MATLAB. Can anyone assist for the following question for the information enter into the program? Use normplot ? Plot normal probability plot for a random sample of size 60 from N(0,1). Thanks.
From: Bruce on 5 Feb 2010 05:14 "Kitty Huang" <kittyzl.huang(a)hotmail.com> wrote in message <hjtrj6$o9u$1(a)fred.mathworks.com>... > Hi, > I am new for MATLAB. Can anyone assist for the following question for the information enter into the program? Use normplot ? > > Plot normal probability plot for a random sample of size 60 from N(0,1). > > Thanks. Hello Kitty, The script below will do the normal probability plot for you. You can alter the size of the sample by changing the 1st parameter of rand. Best of luck learning MATLAB. Bruce %you need the Symbolic Math toolbox as well as MATLAB for this script. p=rand(60,1); %col. vector of 60 random numbers from N(0,1) is your random sample mu = mean(p); %arithmetic mean sigma = std(p); %standard deviation mu = 0; sigma = 1; % produces std normal distribution if sigma^2 ~= 0 % standard deviation squared must be non-zero %probability density function of normal distribution curve %i.e. Gaussian function. pdf = @(x) exp( -(x-mu).^2./2*sigma^2 )/(sqrt(2*pi*sigma^2)); %plot the normal probability curve ezplot( pdf, [mu - 3*sigma, mu + 3*sigma] ); grid on; end;
From: Bruce on 5 Feb 2010 17:50 "Bruce " <bremove.thisraineorama(a)gmail.com> wrote in message <hkgr1f$m0s$1(a)fred.mathworks.com>... > "Kitty Huang" <kittyzl.huang(a)hotmail.com> wrote in message <hjtrj6$o9u$1(a)fred.mathworks.com>... > > Hi, > > I am new for MATLAB. Can anyone assist for the following question for the information enter into the program? Use normplot ? > > > > Plot normal probability plot for a random sample of size 60 from N(0,1). > > > > Thanks. > > Hello Kitty, > > The script below will do the normal probability plot for you. You can > alter the size of the sample by changing the 1st parameter of rand. > Best of luck learning MATLAB. > > Bruce > > %you need the Symbolic Math toolbox as well as MATLAB for this script. > p=rand(60,1); %col. vector of 60 random numbers from N(0,1) is your random sample > mu = mean(p); %arithmetic mean > sigma = std(p); %standard deviation > mu = 0; sigma = 1; % produces std normal distribution > if sigma^2 ~= 0 % standard deviation squared must be non-zero > %probability density function of normal distribution curve > %i.e. Gaussian function. > pdf = @(x) exp( -(x-mu).^2./2*sigma^2 )/(sqrt(2*pi*sigma^2)); > %plot the normal probability curve > ezplot( pdf, [mu - 3*sigma, mu + 3*sigma] ); > grid on; > end; Hello Kitty, I forgot to say you need to comment out this line: % mu = 0; sigma = 1; % produces std normal distribution otherwise the random data you want, p, will never get used. I only put the line above in my code to show you my code can produce the standard normal distribution when it has to as the random data, p, is unlikely to ever produce it. Regards Bruce
|
Pages: 1 Prev: How to write a for loop for multiple variables Next: cannot find matlab.hpp header file |