Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

pdf Class Reference

Calculate the probability denisty function from a set of data. More...

#include <pdf.h>

List of all members.

Public Methods

 pdf ()
 ~pdf ()
double pdf_stddev (const double *v, const size_t N)

Private Methods

 pdf (const pdf &rhs)
void normalize (double *norm, const double *v, const size_t N)


Detailed Description

Calculate the probability denisty function from a set of data.

This is a discrete version of the Probability Density Function (PDF), which for continuous functions can be expressed in non-discrete form. Of course many of the things that we measure cannot be expressed as continuous functions.

The PDF is a histogram, where each histogram bin represents the probability of the data being in the range over which the bin is calculated. The sum of all the bins will be 1.

The PDF is constructed so that it has a zero mean. 64 bins are used in calculating he histogram, so there should be sufficiently more than 64 items.

Definition at line 26 of file pdf.h.


Constructor & Destructor Documentation

pdf::pdf ( const pdf & rhs ) [private]
 

pdf::pdf ( ) [inline]
 

Definition at line 33 of file pdf.h.

00033 {};

pdf::~pdf ( ) [inline]
 

Definition at line 34 of file pdf.h.

00034 {}


Member Function Documentation

void pdf::normalize ( double * norm,
const double * v,
const size_t N ) [private]
 

Definition at line 6 of file pdf.cpp.

Referenced by pdf_stddev().

00007 {
00008   double sum = 0;
00009   size_t i;
00010   for (i = 0; i < N; i++) {
00011     sum = sum + v[i];
00012   }
00013   double mean = 0;
00014   if (sum != 0) {
00015     double mean = sum / N;
00016   }
00017   for (i = 0; i < N; i++)
00018     norm[i] = v[i] - mean;
00019 } // normalize

double pdf::pdf_stddev ( const double * v,
const size_t N )
 

Definition at line 23 of file pdf.cpp.

00024 {
00025   double pdf_sigma = 0.0;
00026   if (v != 0 && N != 0) {
00027     // On average, 4 elements per bin
00028     // const size_t num_bins = N >> 2;
00029     const size_t num_bins = 64;
00030     histogram::bin_vec binz( num_bins );
00031     histogram histo;
00032 
00033     histo.calculate( v, N, binz );
00034     double *freq = new double[ num_bins ];
00035 
00036     // calculate the PDF from the integer frequency counts
00037     for (size_t i = 0; i < num_bins; i++) {
00038       freq[i] = 0.0;
00039       size_t count = static_cast<size_t>( binz[i] );
00040       double val = 0.0;
00041       if (count > 0) {
00042         freq[i] = static_cast<double>(count)/static_cast<double>(N);
00043         val = freq[i];
00044       }
00045       // printf("%2d %9.6f\n", i, val );
00046     }
00047     // printf("\n\n");
00048 
00049     double *norm = new double[ num_bins ];
00050 
00051     normalize(norm, freq, num_bins);
00052 
00053     stddev sd;
00054     pdf_sigma = sd.sd( norm, num_bins );
00055 
00056     delete [] norm;
00057     delete [] freq;
00058   }
00059   return pdf_sigma;
00060 } // pdf


The documentation for this class was generated from the following files:
Generated at Thu May 22 21:12:35 2003 for Hurst Exponent Calculation and Supporting Statistics by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001