help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Determining if samples are normal


From: Doug Stewart
Subject: Re: Determining if samples are normal
Date: Sun, 25 Sep 2005 15:45:31 -0500
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

I didn't claim it was perfect :-)
The sort answer is that I am not a very good Octave programmer.
I also never thought of any one wanting it - so if any one thinks it is worth doing then it should be fixed up and the put in Octave forge?

I have many M files that I write up and use once or twice and then they just sit there, so I don't put a lot of effort into making them user friendly.
Doug

Robert A. Macy wrote:

curious,

why the for loop and not
q1=(1:n)/(n+1);
...?

and why [p yf]=polyfit( ...etc...);

when p=polyfit(...) is faster?

           - Robert -

On Sun, 25 Sep 2005 14:31:07 -0500
Doug Stewart <address@hidden> wrote:
Søren Hauberg wrote:

Hi,
Does anybody know how I can test wether or not some
samples are
normaly distributed? I tried graphical methods, such as
looking at
histograms and qqplots, but I don't trust my own
judgement enough to
use graphical methods.

/Søren
Here is how I did it:
You warp it by the normal curve so that 'normal' data
will produce a streight line.
Then you check how streight your line is with the cor()
function..
A cor=1 is perfect fit.
A cor =.5 is there is a 50% chance it is from a normal
distribution. etc.
The number of data points is also important. etc.
So if you get cor>.9 you can be happy.


## Copyright (C) 2005 doug
##
## This program is free software; you can redistribute it
and/or modify
## it under the terms of the GNU General Public License
as published by
## the Free Software Foundation; either version 2 of the
License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will
be useful,
## but WITHOUT ANY WARRANTY; without even the implied
warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General
Public License
## along with this program; if not, write to the Free
Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston,
MA 02111-1307 USA

## nt(y)
## This is a normality test ie. is the data in y a sample
from a normaly distributed
## population?  If this graph is a streight line then it
is.

## Author: Doug Stewart
##
## 2005-02-10 doug
## * Initial revision

function [ ret ] = nt (y)
y1=sort(y);
n=length(y);
for k=1:n
   q1(k)=k/(n+1)
end
y3=normal_inv(q1);

## now find the streight line that fits through the curve
[p yf]=polyfit(y3,y1',1);
p
##p(2) is the y crossing and is the sample mean
##p(1) is the slope and is the  sample standard deveation
 std
w3=p(2)+p(1).*y3;
plot(y3,y1,y3,w3)

## now test how good the fit was
## it should be greater than   ?     .997
cor(y1,w3)
endfunction







----




-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]