Thread Subject: normally distributed random integers

Subject: normally distributed random integers

From: Anders Stephansen

Date: 4 Sep, 2009 10:14:03

Message: 1 of 5

Hi.
I'm trying to find a way to generate a set of random integers with a given mean and standard deviation, much like the randn function (except the randn function generates floats). Any ideas?

Subject: normally distributed random integers

From: John D'Errico

Date: 4 Sep, 2009 10:41:02

Message: 2 of 5

"Anders Stephansen" <aswsw@start.no> wrote in message <h7qp9b$mt4$1@fred.mathworks.com>...
> Hi.
> I'm trying to find a way to generate a set of random integers with a given mean and standard deviation, much like the randn function (except the randn function generates floats). Any ideas?

They won't be normally distributed if they are integers.
By definition of the normal distribution, they won't
be normal, since it is continuous.

So why not use randn, and then just round them?
(This may introduce a small bias into the mean.)

John

Subject: normally distributed random integers

From: Ulf Graewe

Date: 4 Sep, 2009 10:48:02

Message: 3 of 5


> I'm trying to find a way to generate a set of random integers with a given mean and standard deviation, much like the randn function (except the randn function generates floats). Any ideas?

something like:
scale = 10;
bias = 5;
N = 100;
int_gauss = round(scale*randn(N,1)+bias);

Subject: normally distributed random integers

From: Bruno Luong

Date: 4 Sep, 2009 12:02:01

Message: 4 of 5

"Anders Stephansen" <aswsw@start.no> wrote in message <h7qp9b$mt4$1@fred.mathworks.com>...
> Hi.
> I'm trying to find a way to generate a set of random integers with a given mean and standard deviation, much like the randn function (except the randn function generates floats). Any ideas?

You might take a look at Poisson's pdf which converges toward a normal pdf when lambda parameter goes to infinity (select a large one is OK):

http://en.wikipedia.org/wiki/Poisson_distribution

Bruno

Subject: normally distributed random integers

From: stephans

Date: 4 Sep, 2009 13:11:03

Message: 5 of 5

"John D'Errico" <woodchips@rochester.rr.com> wrote in message <h7qqru$hf9$1@fred.mathworks.com>...
>
> They won't be normally distributed if they are integers.
> By definition of the normal distribution, they won't
> be normal, since it is continuous.
>
> So why not use randn, and then just round them?
> (This may introduce a small bias into the mean.)
>
> John

Oh, sorry. They don't to be normal, they just need to have a given standard deviation and mean. Seems like a rounded randn set works fine.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
random Sprinceana 4 Sep, 2009 06:44:00
random integers... Sprinceana 4 Sep, 2009 06:43:55
rssFeed for this Thread

Contact us at files@mathworks.com