%this version is for finding p given x function chisq=chisq(x); global df; cons=2^(df/2)*gamma(df/2); chisq=x.^((df-2)/2).*exp(-x./2)/cons; end;