Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: how to generate a gaussian distribution using random number generator
Replies: 3   Last Post: Jul 8, 2013 2:10 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Steven Lord

Posts: 17,944
Registered: 12/7/04
Re: how to generate a gaussian distribution using random number generator
Posted: Jul 8, 2013 2:10 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply



"faraz.a " <syedfarazahmed@yahoo.com> wrote in message
news:kr2df9$7cq$1@newscl01ah.mathworks.com...
> i want to generate 50,000 samples according to the gaussian distribution
> using random number generator where sigma=1 and mean=0 X is a normally
> distributed random variable N(0,?2). mean=0 variance=1
>
> I did this R=randn(50000)
>
> i got an error
>
> Error using randn
> Out of memory. Type HELP MEMORY for your options.


As dpb said, you're trying to create a 50k-by-50k matrix. You don't have a
contiguous block of memory large enough to hold that.

> and if i am using R=randn(50000,1);
> hist(R)
>
> this generated a distribution but the y label was ranging from -4 to 5. I
> want it from -infinity to +infinity


Since you don't have an infinitely wide screen (even Weird Al Yankovic's
friend Frank only had a 2000 inch TV) it's going to be difficult for you to
plot an infinitely long line. If you want to "cheat" you could simply
relabel the first and last last points in the axes with -Inf and Inf. See
the example on this page for how to do that.

http://www.mathworks.com/help/matlab/creating_plots/setting-axis-parameters.html

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.