help-octave
[Top][All Lists]

## RE: Is chisquare_inv broken?

 From: Ted Harding Subject: RE: Is chisquare_inv broken? Date: Wed, 29 Dec 2004 20:26:03 -0000 (GMT)

```On 29-Dec-04 Joe Koski wrote:
> I'm trying to calculate the probability that the probability
> density function of fire temperatures generated with
> computational fluid dynamics is consistent with some
> experimentally determined pdfs of fire temperatures.
>
> All goes well while constructing the chisquare distribution
> value and the number of degrees-of-freedom, until I attempt
> to find the probability of occurrence related to the chisquare
> value and the degrees-of-freedom.
> At that point, the octave-forge routine chisquare_inv consistently
>
> For example, for chisquare = 10, and 10 degrees-of-freedom,
> I should get a probability value somewhat less than 0.5.
> With chisquare_inv, I get
>
> octave:5> prob = chisquare_inv(10,10)
> prob = NaN
>
> I'm doing this with octave-2.1.64 and octave-forge-2004.11.16 on my Mac
> running OS X 10.3.7.
>
> Is chisquare_inv broken, or am I doing something wrong?

You're backwards-on! X = chisquare_inv(p,n) computes the chisquare
value X such that, for a given probability p,

Prob(chisquare <= X) = p

whereas what you seem to be seeking is the value of p for given X.

Since you've given it a p > 1 to chew on, it naturally spits
back "NaN".

What you should be using is chisquare_cdf:

octave:8> chisquare_cdf(10,10)
ans = 0.55951

Note that this is Prob(chisquare <= X). From what you say,
I think you're really looking for Prob(chisquare > X), which
is

octave:9> 1 - chisquare_cdf(10,10)
ans = 0.44049

(much as you expected!).

Cheers,
Ted.

--------------------------------------------------------------------
Fax-to-email: +44 (0)870 094 0861  [NB: New number!]
Date: 29-Dec-04                                       Time: 20:26:03
------------------------------ XFMail ------------------------------

-------------------------------------------------------------
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
-------------------------------------------------------------

```