JWST Pipeline routines in IDL

A collection mantained by M. Robberto

single page | use frames     summary     class     fields     routine details     file attributes

./

GLSFit.pro


GLS routines to calculate linear fit

NAME: MPCHILIM

AUTHOR: Craig B. Markwardt, NASA/GSFC Code 662, Greenbelt, MD 20770 craigm@lheamail.gsfc.nasa.gov UPDATED VERSIONs can be found on my WEB PAGE: http://cow.physics.wisc.edu/~craigm/idl/idl.html

PURPOSE: Compute confidence limits for chi-square statistic

MAJOR TOPICS: Curve and Surface Fitting, Statistics

CALLING SEQUENCE: DELCHI = MPCHILIM(PROB, DOF, [/SIGMA, /CLEVEL, /SLEVEL ])

DESCRIPTION:

The function MPCHILIM() computes confidence limits of the chi-square statistic for a desired probability level. The returned values, DELCHI, are the limiting chi-squared values: a chi-squared value of greater than DELCHI will occur by chance with probability PROB:

P_CHI(CHI > DELCHI; DOF) = PROB

In specifying the probability level the user has three choices:

* give the confidence level (default);

* give the significance level (i.e., 1 - confidence level) and pass the /SLEVEL keyword; OR

* give the "sigma" of the probability (i.e., compute the probability based on the normal distribution) and pass the /SIGMA keyword.

Note that /SLEVEL, /CLEVEL and /SIGMA are mutually exclusive.

INPUTS:

PROB - scalar or vector number, giving the desired probability level as described above.

DOF - scalar or vector number, giving the number of degrees of freedom in the chi-square distribution.

RETURNS:

Returns a scalar or vector of chi-square confidence limits.

KEYWORD PARAMETERS:

SLEVEL - if set, then PROB describes the significance level.

CLEVEL - if set, then PROB describes the confidence level (default).

SIGMA - if set, then PROB is the number of "sigma" away from the mean in the normal distribution.

EXAMPLES:

print, mpchilim(0.99d, 2d, /clevel)

Print the 99% confidence limit for a chi-squared of 2 degrees of freedom.

print, mpchilim(5d, 2d, /sigma)

Print the "5 sigma" confidence limit for a chi-squared of 2 degrees of freedom. Here "5 sigma" indicates the gaussian probability of a 5 sigma event or greater. P_GAUSS(5D) = 1D - 5.7330314e-07

REFERENCES:

Algorithms taken from CEPHES special function library, by Stephen Moshier. (http://www.netlib.org/cephes/)

MODIFICATION HISTORY: Completed, 1999, CM Documented, 16 Nov 2001, CM Reduced obtrusiveness of common block and math error handling, 18 Nov 2001, CM Convert to IDL 5 array syntax (!), 16 Jul 2006, CM Move STRICTARR compile option inside each function/procedure, 9 Oct 2006 Add usage message, 24 Nov 2006, CM Usage message with /CONTINUE, 23 Sep 2009, CM

$Id: mpchilim.pro,v 1.8 2009/09/23 20:12:46 craigm Exp $

Routines

result = linearize_mr(time, ramp)

GLS routines to calculate linear fit

run_GLSfit

GLS routines to calculate linear fit

result = covar2ellipse(covar, nsigma=nsigma)

NAME: COVAR2ELLIPSE()

cephes_setmachar
result = cephes_polevl(x, coef)

function

result = cephes_ndtri(y0)
result = cephes_igam(a, x)

Incomplete gamma integral

result = cephes_igamc(a, x)

Complemented incomplete gamma integral

result = cephes_igami(a, y0)

Inverse of complemented imcomplete gamma integral

result = mpchilim(p, dof, sigma=sigma, clevel=clevel, slevel=slevel)

GLS routines to calculate linear fit

openeps, nomefile

GLS routines to calculate linear fit

closeps

GLS routines to calculate linear fit

Routine details

top source linearize_mr

result = linearize_mr(time, ramp)

GLS routines to calculate linear fit

Parameters

time
ramp

Statistics

Lines:
99 lines
McCabe complexity:
6

top source run_GLSfit

run_GLSfit

GLS routines to calculate linear fit

Statistics

Lines:
74 lines
McCabe complexity:
9

top source covar2ellipse

result = covar2ellipse(covar, nsigma=nsigma)

NAME: COVAR2ELLIPSE()

PURPOSE: Given a 2D covariance matrix, compute the parameters of the confidence ellipse.

INPUTS: covar - 2D covariance matrix

OPTIONAL INPUTS: nsigma - desired confidence interval; default is 1-sigma

KEYWORD PARAMETERS:

OUTPUTS: ellipse - data structure containing the parameters of the ellipse

OPTIONAL OUTPUTS:

COMMENTS: Based entirely on D. Coe's beautiful Fisher-matrix write-up, astro-ph/0906.3123.

EXAMPLES:

MODIFICATION HISTORY: J. Moustakas, 2010 Jul 09, UCSD

Copyright (C) 2010, John Moustakas

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.

Parameters

covar

Keywords

nsigma

Statistics

Lines:
25 lines
McCabe complexity:
1

top source cephes_setmachar

cephes_setmachar

Statistics

Lines:
21 lines
McCabe complexity:
2

top source cephes_polevl

result = cephes_polevl(x, coef)

function

Parameters

x
coef

Statistics

Lines:
7 lines
McCabe complexity:
1

top source cephes_ndtri

result = cephes_ndtri(y0)

Parameters

y0

Statistics

Lines:
118 lines
McCabe complexity:
6

top source cephes_igam

result = cephes_igam(a, x)

Incomplete gamma integral

SYNOPSIS:

double a, x, y, igam();

y = igam( a, x );

DESCRIPTION:

The function is defined by

x - 1 | | -t a-1 igam(a,x) = ----- | e t dt. - | | | (a) - 0

In this implementation both arguments must be positive. The integral is evaluated by either a power series or continued fraction expansion, depending on the relative values of a and x.

ACCURACY:

Relative error: arithmetic domain # trials peak rms IEEE 0,30 200000 3.6e-14 2.9e-15 IEEE 0,100 300000 9.9e-14 1.5e-14

Parameters

a
x

Statistics

Lines:
63 lines
McCabe complexity:
1

top source cephes_igamc

result = cephes_igamc(a, x)

Complemented incomplete gamma integral

SYNOPSIS:

double a, x, y, igamc();

y = igamc( a, x );

DESCRIPTION:

The function is defined by

igamc(a,x) = 1 - igam(a,x)

inf. - 1 | | -t a-1 = ----- | e t dt. - | | | (a) - x

In this implementation both arguments must be positive. The integral is evaluated by either a power series or continued fraction expansion, depending on the relative values of a and x.

ACCURACY:

Tested at random a, x. a x Relative error: arithmetic domain domain # trials peak rms IEEE 0.5,100 0,100 200000 1.9e-14 1.7e-15 IEEE 0.01,0.5 0,100 200000 1.4e-13 1.6e-15

Parameters

a
x

Statistics

Lines:
96 lines
McCabe complexity:
3

top source cephes_igami

result = cephes_igami(a, y0)

Inverse of complemented imcomplete gamma integral

SYNOPSIS:

double a, x, p, igami();

x = igami( a, p );

DESCRIPTION:

Given p, the function finds x such that

igamc( a, x ) = p.

Starting with the approximate value

3 x = a t

where

t = 1 - d - ndtri(p) sqrt(d)

and

d = 1/9a,

the routine performs up to 10 Newton iterations to find the root of igamc(a,x) - p = 0.

ACCURACY:

Tested at random a, p in the intervals indicated.

a p Relative error: arithmetic domain domain # trials peak rms IEEE 0.5,100 0,0.5 100000 1.0e-14 1.7e-15 IEEE 0.01,0.5 0,0.5 100000 9.0e-14 3.4e-15 IEEE 0.5,10000 0,0.5 20000 2.3e-13 3.8e-14

Parameters

a
y0

Statistics

Lines:
145 lines
McCabe complexity:
21

top source mpchilim

result = mpchilim(p, dof, sigma=sigma, clevel=clevel, slevel=slevel)

GLS routines to calculate linear fit

Parameters

p
dof

Keywords

sigma
clevel
slevel

Statistics

Lines:
35 lines
McCabe complexity:
6

top source openeps

openeps, nomefile

GLS routines to calculate linear fit

Parameters

nomefile

Statistics

Lines:
6 lines
McCabe complexity:
1

top source closeps

closeps

GLS routines to calculate linear fit

Statistics

Lines:
5 lines
McCabe complexity:
1

File attributes

Modification date: Tue May 7 10:44:08 2013
Lines: 949