Main Page | Modules | Data Structures | File List | Data Fields | Globals | Related Pages

lib/stats.c File Reference

Statistics utilities, to be included in C_mathlibs. More...

Go to the source code of this file.

Functions

void frame_stats (const IMAGE2D *frame, double *mean, double *sigma, double *median, double *sigmed)
 Statistic elements of a frame.

SPECTRUM * array_histo (const double *array, int npts, double min, double max, int nbin)
 Histogram of a (double) vector.

SPECTRUM * subframe_histo (const IMAGE2D *frame, int imin, int imax, int jmin, int jmax, double min, double max, int nbin)
 Histogram of a subframe.

SPECTRUM * frame_histo (const IMAGE2D *frame, double min, double max, int nbin)
 Histogram of a frame.

double histo_threshold (const SPECTRUM *histospec, float frac)
 Invert an histogram.

float median_f (const float x[], int n)
 Float wrapper to statistic (double) function "median".

double mean_sig_f (const float x[], int n, double *mean, double *sigma)
 Statistics (mean+sigma) on float array.

void minmax (const double x[], int n, double *min, double *max, int *imin, int *imax)
 Find the min and max (and associated index) in a double array.

void minmax_f (const float x[], int n, float *min, float *max, int *imin, int *imax)
 Find the min and max (and associated index) in a float array.

int locate_sorted (const double x[], int n, double x0)
 Locate a value in a sorted array.

void invert_indexx (int idx[], int n)
 Compute the rank, i.e. invert the sorting index.

int Fit_polynom2 (float *x, float *y, int npts, int input_deg, int *output_deg, float *coef, float *dy, float *chi2)
 Conversion to double of Fit_polynom.

void filter_med_array (float array[], int npts, int radius, float f_array[])
 Median filter on float array.


Detailed Description

Statistics utilities, to be included in C_mathlibs.

Copyright:
(c) 2002 INPL
Date:
Fri Mar 19 14:24:33 2004
Author:
Yannick Copin <y.copin@ipnl.in2p3.fr>

Author
ycopin
Version:
Revision
1.2
Id
stats.c,v 1.2 2005/08/02 01:05:15 ycopin Exp

Note:
Previously in extract/lib/stats.c (v1.16) and calib/lib/stats.c (v1.1).

Definition in file stats.c.


Function Documentation

void frame_stats const IMAGE2D *  frame,
double *  mean,
double *  sigma,
double *  median,
double *  sigmed
 

Statistic elements of a frame.

Compute statistic elements (mean,dispersion and median, median dispersion if required) of frame. Median and median dispersion are computed if both pointers are non-NULL

Parameters:
frame Input frame
mean Arithmetic mean $\mu$
sigma Arithmetic dispersion $\sigma$: $\sigma^2 = \frac{n\sum p_{ij}^2 - (\sum p_{ij})^2}{n(n-1)}$
median Median $m$ (or NULL if not needed)
sigmed Median dispersion (i.e. median of $|p_{ij}-m|$) (or NULL if not needed)

Definition at line 41 of file stats.c.

Referenced by main().

SPECTRUM* array_histo const double *  array,
int  npts,
double  min,
double  max,
int  nbin
 

Histogram of a (double) vector.

Compute the histogram -- with ~nbin bins between min and max -- of a vector, and return it as a memory spectrum. If nbin>0, there is indeed nbin bins. If nbin<0, there are two extra outer bins for the values outside the range [min,max].

Parameters:
array input (double) vector
npts of size npts
min 
max min and max of the histogram range
nbin number of bins (can be negative, see description)
Returns:
pointer to the histogram memory spectrum

Definition at line 100 of file stats.c.

Referenced by main(), and subframe_histo().

SPECTRUM* subframe_histo const IMAGE2D *  frame,
int  imin,
int  imax,
int  jmin,
int  jmax,
double  min,
double  max,
int  nbin
 

Histogram of a subframe.

Compute the histogram -- with ~nbin bins between min and max -- of subframe [imin,jmin:imax,jmax], and return it as a memory spectrum (see array_histo).

Parameters:
frame input frame
imin 
imax 
jmin 
jmax subframe definition [px]
min 
max min and max of the histogram range
nbin number of bins (can be negative)
Returns:
pointer to the histogram memory spectrum
Warning:
There's no checking for validity of subframe.

Definition at line 169 of file stats.c.

References array_histo().

Referenced by frame_histo(), and plot_set_bkgnd().

Here is the call graph for this function:

SPECTRUM* frame_histo const IMAGE2D *  frame,
double  min,
double  max,
int  nbin
 

Histogram of a frame.

Compute the histogram -- with ~nbin bins between min and max -- of a frame, and return it as a memory spectrum (see array_histo).

Parameters:
frame input frame
min 
max min and max of the histogram range
nbin number of bins (can be negative)
Returns:
pointer to the histogram memory spectrum

Definition at line 208 of file stats.c.

References subframe_histo().

Referenced by main().

Here is the call graph for this function:

double histo_threshold const SPECTRUM *  histospec,
float  frac
 

Invert an histogram.

According to the histogram stored in the input spectrum, computes the threshold so that a given fraction of the population is below.

Parameters:
histospec input histogram spectrum, as computed from frame_histo
frac fraction of the population that should be below
Returns:
threshold

Definition at line 230 of file stats.c.

Referenced by main(), and plot_set_bkgnd().

float median_f const float  x[],
int  n
 

Float wrapper to statistic (double) function "median".

Parameters:
x float array
n nb of points
Returns:
(float)median

Definition at line 263 of file stats.c.

References x.

Referenced by main().

double mean_sig_f const float  x[],
int  n,
double *  mean,
double *  sigma
 

Statistics (mean+sigma) on float array.

Parameters:
x float array
n nb of points
mean arithmetic mean
sigma arithmetic dispersion (n-1)
Returns:
mean
Note:
Similar to gsl_stats_mean and gsl_stats_sd_m

Definition at line 294 of file stats.c.

References x.

Referenced by main().

void minmax const double  x[],
int  n,
double *  min,
double *  max,
int *  imin,
int *  imax
 

Find the min and max (and associated index) in a double array.

Parameters:
x input array
n size of input array
min minimum value of the input array
max maximum value of the input array
imin index of the minimum value
imax index of the maximum value
Note:
Similar to gsl_stats_minmax_index

Definition at line 325 of file stats.c.

References x.

Referenced by main().

void minmax_f const float  x[],
int  n,
float *  min,
float *  max,
int *  imin,
int *  imax
 

Find the min and max (and associated index) in a float array.

Parameters:
x input array
n size of input array
min minimum value of the input array
max maximum value of the input array
imin index of the minimum value
imax index of the maximum value
Note:
Similar to gsl_stats_minmax_index

Definition at line 351 of file stats.c.

References x.

Referenced by main(), and select_mpup_sharpest_smooth().

int locate_sorted const double  x[],
int  n,
double  x0
 

Locate a value in a sorted array.

Parameters:
x input array (monotonely sorted)
n input array length
x0 target value
Returns:
Index i (in -1,n-1) such that x[i] <= x0 < x[i+1]
Note:
Log_2(n) algorithm adapted from locate of NRC.

Definition at line 375 of file stats.c.

References x.

void invert_indexx int  idx[],
int  n
 

Compute the rank, i.e. invert the sorting index.

At input, idx has been computed (by e.g. indexx) according to an external array such as array[idx[i]] is in increasing order. At output, idx contains the rank of array[i], i.e. idx_new[idx_old[i]] = i.

Parameters:
idx Sorting/ranking index
n Size of the array

Definition at line 407 of file stats.c.

Referenced by main().

int Fit_polynom2 float *  x,
float *  y,
int  npts,
int  input_deg,
int *  output_deg,
float *  coef,
float *  dy,
float *  chi2
 

Conversion to double of Fit_polynom.

Routine Fit_polynom in IFU_C_mathlibs-6.1 makes its internal computations in float, which is unsufficient.

Definition at line 452 of file stats.c.

References x.

Referenced by main().

void filter_med_array float  array[],
int  npts,
int  radius,
float  f_array[]
 

Median filter on float array.

Parameters:
array Input array
npts Size of input array
radius Half-width of filtering window
f_array Output median-filtered array

Definition at line 584 of file stats.c.

Referenced by compute_mean_spec().


Generated on Thu Oct 27 00:00:21 2005 for Snifs by doxygen 1.3.5