[R] Standard Deviation Distribution

Erich Neuwirth erich.neuwirth at univie.ac.at
Sun Jun 18 13:30:08 CEST 2006


davidr at rhotrading.com wrote:
> > sddist
>>> > >>
> > function(s,n) {
> > sig2 <- n*s*s/(n-1)
> > 2*(n/(2*sig2))^((n-1)/2) / gamma((n-1)/2) * exp(-n*s*s/(2*sig2)) *
s^(n-2)
> > }


There is another way using more statistical knowledge:
Building on functions already available in R
one may note that the easiest way of defining
sddist is

sddist<-function(s,n) dchisq(n*s^2,n-1)*2*n*s

Plotting this function for n in seq(2,12,2)
reproduces the graph in Mathworld.

The idea is the following:
given a random variable x with a chisquare distribution with
df n-1, s can be defined by s=sqrt(x/n) and therefore
x=n*s^2

If F and G are the cumulative distribution functions of x and s
and f and g are the density functions of x and s, then we have
G(s)=F(n*s^2) and therefore
g(s)=f(n*s^2)*2*n*s
-- 
Erich Neuwirth, University of Vienna
Faculty of Computer Science
Computer Supported Didactics Working Group
Visit our SunSITE at http://sunsite.univie.ac.at
Phone: +43-1-4277-39464 Fax: +43-1-4277-39459



More information about the R-help mailing list