% this version of chiinv finds x given p function chiinv=chiinv(x); global p; p=x; chiinv=fsolve('cumchi',1); end;