Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
how to calculate 95% probability interval of elements in a matrix

Subject: how to calculate 95% probability interval of elements in a matrix

From: Sam

Date: 15 May, 2013 21:24:10

Message: 1 of 8

Hi,

How to calculate the 95% probability interval of the elements in a matrix? if all the elements in the matrix follow normal distribution, it is the [mean-2sigma, mean+2sigma]. What if it is not normal distribution? Is there still a way to calculate it?

Thanks!

Sam

Subject: how to calculate 95% probability interval of elements in a matrix

From: Nasser M. Abbasi

Date: 15 May, 2013 21:31:32

Message: 2 of 8

On 5/15/2013 4:24 PM, Sam wrote:
> Hi,
>
> How to calculate the 95% probability interval of the elements in a matrix?


maybe regress. Not sure, but look it up:

http://www.mathworks.com/help/stats/regress.html

Subject: how to calculate 95% probability interval of elements in a matrix

From: Sam

Date: 15 May, 2013 23:01:09

Message: 3 of 8

"Nasser M. Abbasi" wrote in message <kn0urg$gpj$1@speranza.aioe.org>...
> On 5/15/2013 4:24 PM, Sam wrote:
> > Hi,
> >
> > How to calculate the 95% probability interval of the elements in a matrix?
>
>
> maybe regress. Not sure, but look it up:
>
> http://www.mathworks.com/help/stats/regress.html
>

Thanks, Nasser! But I am not doing regression. I just want to know if I put all those elements in matrix into distribution, above what value or under what value will considered as outside 95% probability.

Subject: how to calculate 95% probability interval of elements in a matrix

From: Bruno Luong

Date: 16 May, 2013 06:00:10

Message: 4 of 8

"Sam" wrote in message <kn0udq$n06$1@newscl01ah.mathworks.com>...
> Hi,
>
> How to calculate the 95% probability interval of the elements in a matrix? if all the elements in the matrix follow normal distribution, it is the [mean-2sigma, mean+2sigma].

To be exact, it is the interval of 95% is (mean-x*sigma,mean+x*sigma)

>> x = erfinv(0.95)*sqrt(2) % ~ 1.959963984540054

>> r=randn(1,1e7);

>> sum(abs(r)< 1.959963984540054)/numel(r)

ans =

   0.949882600000000

>> sum(abs(r)< 2)/numel(r)

ans =

   0.954334300000000


> What if it is not normal distribution? Is there still a way to calculate it?

Your question sounds like "what is a color of a non-red car ?".

Bruno

Subject: how to calculate 95% probability interval of elements in a matrix

From: Bjorn Gustavsson

Date: 16 May, 2013 10:07:10

Message: 5 of 8

"Sam" wrote in message <kn143l$94c$1@newscl01ah.mathworks.com>...
> "Nasser M. Abbasi" wrote in message <kn0urg$gpj$1@speranza.aioe.org>...
> > On 5/15/2013 4:24 PM, Sam wrote:
> > > Hi,
> > >
> > > How to calculate the 95% probability interval of the elements in a matrix?
> >
> >
> > maybe regress. Not sure, but look it up:
> >
> > http://www.mathworks.com/help/stats/regress.html
> >
>
> Thanks, Nasser! But I am not doing regression. I just want to know if I put all those elements in matrix into distribution, above what value or under what value will considered as outside 95% probability.

Brutest force way: sort your matrix count off 2.5 percent of the elements from either edge, then there you have something like your 95% intervall.

HTH,

Subject: how to calculate 95% probability interval of elements in a matrix

From: Sam

Date: 16 May, 2013 15:31:11

Message: 6 of 8

"Bjorn Gustavsson" <bjonr@irf.se> wrote in message <kn2b4e$k0m$1@newscl01ah.mathworks.com>...
> "Sam" wrote in message <kn143l$94c$1@newscl01ah.mathworks.com>...
> > "Nasser M. Abbasi" wrote in message <kn0urg$gpj$1@speranza.aioe.org>...
> > > On 5/15/2013 4:24 PM, Sam wrote:
> > > > Hi,
> > > >
> > > > How to calculate the 95% probability interval of the elements in a matrix?
> > >
> > >
> > > maybe regress. Not sure, but look it up:
> > >
> > > http://www.mathworks.com/help/stats/regress.html
> > >
> >
> > Thanks, Nasser! But I am not doing regression. I just want to know if I put all those elements in matrix into distribution, above what value or under what value will considered as outside 95% probability.
>
> Brutest force way: sort your matrix count off 2.5 percent of the elements from either edge, then there you have something like your 95% intervall.
>
> HTH,

Thanks, that is what I need! I hope Mathwork can come up some function for this.

Subject: how to calculate 95% probability interval of elements in a matrix

From: Bruno Luong

Date: 16 May, 2013 18:11:10

Message: 7 of 8

"Sam" wrote in message <kn2u3v$k0t$1@newscl01ah.mathworks.com>...

>
> Thanks, that is what I need! I hope Mathwork can come up some function for this.

Well, not so difficult to make this function I would say:

% Example data
r=randn(1,1e6);

bracket95fun = @(r) interp1(linspace(0,100,length(r)),sort(r),[2.5 97.5]);
bracket = bracket95fun(r)

% Bruno

Subject: how to calculate 95% probability interval of elements in a matrix

From: Sam

Date: 16 May, 2013 21:01:09

Message: 8 of 8

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <kn37ft$lhu$1@newscl01ah.mathworks.com>...
> "Sam" wrote in message <kn2u3v$k0t$1@newscl01ah.mathworks.com>...
>
> >
> > Thanks, that is what I need! I hope Mathwork can come up some function for this.
>
> Well, not so difficult to make this function I would say:
>
> % Example data
> r=randn(1,1e6);
>
> bracket95fun = @(r) interp1(linspace(0,100,length(r)),sort(r),[2.5 97.5]);
> bracket = bracket95fun(r)
>
> % Bruno

Yes, it works!!! Thanks, Bruno!!!

Tags for this Thread

No tags are associated with this thread.

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.

Contact us