pdf1d_gaussian Class Reference

#include <pdf1d_gaussian.h>

Inheritance diagram for pdf1d_gaussian:

Inheritance graph
[legend]

List of all members.


Detailed Description

Class for univariate gaussian.

Definition at line 15 of file pdf1d_gaussian.h.


Public Member Functions

 pdf1d_gaussian ()
 Dflt ctor (creates unit gaussian centred at zero).
 pdf1d_gaussian (double mean, double variance)
 Dflt ctor (creates gaussian with given mean, variance).
virtual ~pdf1d_gaussian ()
 Destructor.
double sd () const
 Return standard deviation.
void set (double mean, double variance)
 Initialise.
void set_mean (double mean)
 Modify just the mean of the distribution.
double log_k () const
 log of normalisation constant for gaussian.
virtual pdf1d_samplernew_sampler () const
 Create a sampler object on the heap.
virtual double log_p (double x) const
 Log of probability density at x.
virtual double cdf (double x) const
 Cumulative Probability (P(x'<x) for x' drawn from the distribution).
virtual bool cdf_is_analytic () const
 Return true if cdf() uses an analytic implementation.
virtual double gradient (double x, double &p) const
 Gradient of PDF at x.
virtual double log_prob_thresh (double pass_proportion) const
 Compute threshold for PDF to pass a given proportion.
virtual double nearest_plausible (double x, double log_p_min) const
 Compute nearest point to x which has a density above a threshold.
short version_no () const
 Version number for I/O.
virtual vcl_string is_a () const
 Name of the class.
virtual bool is_class (vcl_string const &s) const
 Does the name of the class match the argument?.
virtual pdf1d_pdfclone () const
 Create a copy on the heap and return base class pointer.
virtual void print_summary (vcl_ostream &os) const
 Print class to os.
virtual void b_write (vsl_b_ostream &bfs) const
 Save class to binary file stream.
virtual void b_read (vsl_b_istream &bfs)
 Load class from binary file stream.
double mean () const
 Mean of distribution.
double variance () const
 Variance of each dimension.
virtual int n_peaks () const
 Number of peaks of distribution.
virtual double peak (int) const
 Position of the i'th peak.
virtual double operator() (double x) const
 Probability density at x.
virtual double inverse_cdf (double P) const
 The inverse cdf.
virtual bool is_valid_pdf () const
 Return true if the object represents a valid PDF.
void get_samples (vnl_vector< double > &x) const
 Fill x with samples drawn from distribution.
bool write_plot_file (const vcl_string &plot_file, double min_x, double max_x, int n) const
 Write values (x,p(x)) to text file suitable for plotting.

Protected Member Functions

void set_variance (double v)

Private Member Functions

void calc_log_k ()

Private Attributes

double sd_
double k_
double log_k_

Constructor & Destructor Documentation

pdf1d_gaussian::pdf1d_gaussian (  ) 

Dflt ctor (creates unit gaussian centred at zero).

Definition at line 23 of file pdf1d_gaussian.cxx.

pdf1d_gaussian::pdf1d_gaussian ( double  mean,
double  variance 
)

Dflt ctor (creates gaussian with given mean, variance).

Definition at line 28 of file pdf1d_gaussian.cxx.

pdf1d_gaussian::~pdf1d_gaussian (  )  [virtual]

Destructor.

Definition at line 35 of file pdf1d_gaussian.cxx.


Member Function Documentation

void pdf1d_gaussian::calc_log_k (  )  [private]

Definition at line 41 of file pdf1d_gaussian.cxx.

double pdf1d_gaussian::sd (  )  const [inline]

Return standard deviation.

Definition at line 33 of file pdf1d_gaussian.h.

void pdf1d_gaussian::set ( double  mean,
double  variance 
)

Initialise.

Initialise with mean and variance (NOT standard deviation).

Definition at line 48 of file pdf1d_gaussian.cxx.

void pdf1d_gaussian::set_mean ( double  mean  ) 

Modify just the mean of the distribution.

This functions should only be used by builders.

Reimplemented from pdf1d_pdf.

Definition at line 58 of file pdf1d_gaussian.cxx.

double pdf1d_gaussian::log_k (  )  const [inline]

log of normalisation constant for gaussian.

Definition at line 43 of file pdf1d_gaussian.h.

pdf1d_sampler * pdf1d_gaussian::new_sampler (  )  const [virtual]

Create a sampler object on the heap.

Caller is responsible for deletion.

Implements pdf1d_pdf.

Definition at line 67 of file pdf1d_gaussian.cxx.

double pdf1d_gaussian::log_p ( double  x  )  const [virtual]

Log of probability density at x.

This value is also the Normalised Mahalanobis distance from the centroid to the given vector.

Implements pdf1d_pdf.

Definition at line 78 of file pdf1d_gaussian.cxx.

double pdf1d_gaussian::cdf ( double  x  )  const [virtual]

Cumulative Probability (P(x'<x) for x' drawn from the distribution).

Reimplemented from pdf1d_pdf.

Definition at line 88 of file pdf1d_gaussian.cxx.

bool pdf1d_gaussian::cdf_is_analytic (  )  const [virtual]

Return true if cdf() uses an analytic implementation.

Reimplemented from pdf1d_pdf.

Definition at line 95 of file pdf1d_gaussian.cxx.

double pdf1d_gaussian::gradient ( double  x,
double &  p 
) const [virtual]

Gradient of PDF at x.

Implements pdf1d_pdf.

Definition at line 104 of file pdf1d_gaussian.cxx.

double pdf1d_gaussian::log_prob_thresh ( double  pass_proportion  )  const [virtual]

Compute threshold for PDF to pass a given proportion.

Reimplemented from pdf1d_pdf.

Definition at line 119 of file pdf1d_gaussian.cxx.

double pdf1d_gaussian::nearest_plausible ( double  x,
double  log_p_min 
) const [virtual]

Compute nearest point to x which has a density above a threshold.

If log_p(x)>log_p_min then x returned unchanged. Otherwise x is moved (typically up the gradient) until log_p(x)>=log_p_min.

Parameters:
x This may be modified to the nearest plausible position.
log_p_min lower threshold for log_p(x)

Implements pdf1d_pdf.

Definition at line 128 of file pdf1d_gaussian.cxx.

short pdf1d_gaussian::version_no (  )  const

Version number for I/O.

Reimplemented from pdf1d_pdf.

Definition at line 171 of file pdf1d_gaussian.cxx.

vcl_string pdf1d_gaussian::is_a (  )  const [virtual]

Name of the class.

Reimplemented from pdf1d_pdf.

Definition at line 152 of file pdf1d_gaussian.cxx.

bool pdf1d_gaussian::is_class ( vcl_string const &  s  )  const [virtual]

Does the name of the class match the argument?.

Reimplemented from pdf1d_pdf.

Definition at line 162 of file pdf1d_gaussian.cxx.

pdf1d_pdf * pdf1d_gaussian::clone (  )  const [virtual]

Create a copy on the heap and return base class pointer.

Implements pdf1d_pdf.

Definition at line 180 of file pdf1d_gaussian.cxx.

void pdf1d_gaussian::print_summary ( vcl_ostream &  os  )  const [virtual]

Print class to os.

Implements pdf1d_pdf.

Definition at line 190 of file pdf1d_gaussian.cxx.

void pdf1d_gaussian::b_write ( vsl_b_ostream bfs  )  const [virtual]

Save class to binary file stream.

Implements pdf1d_pdf.

Definition at line 200 of file pdf1d_gaussian.cxx.

void pdf1d_gaussian::b_read ( vsl_b_istream bfs  )  [virtual]

Load class from binary file stream.

Implements pdf1d_pdf.

Definition at line 212 of file pdf1d_gaussian.cxx.

void pdf1d_pdf::set_variance ( double  v  )  [inline, protected, inherited]

Definition at line 32 of file pdf1d_pdf.h.

double pdf1d_pdf::mean (  )  const [inline, inherited]

Mean of distribution.

Definition at line 42 of file pdf1d_pdf.h.

double pdf1d_pdf::variance (  )  const [inline, inherited]

Variance of each dimension.

Definition at line 45 of file pdf1d_pdf.h.

virtual int pdf1d_pdf::n_peaks (  )  const [inline, virtual, inherited]

Number of peaks of distribution.

Definition at line 48 of file pdf1d_pdf.h.

virtual double pdf1d_pdf::peak ( int   )  const [inline, virtual, inherited]

Position of the i'th peak.

Definition at line 51 of file pdf1d_pdf.h.

double pdf1d_pdf::operator() ( double  x  )  const [virtual, inherited]

double pdf1d_pdf::inverse_cdf ( double  P  )  const [virtual, inherited]

The inverse cdf.

The inverse cumulative distribution function.

The value of x: P(x'<x) = P for x' drawn from distribution pdf. The default version of this algorithm uses sampling if !cdf_is_analytic(), and Newton-Raphson root finding otherwise.

The value of x: P(x'<x) = P for x' drawn from distribution pdf.

Reimplemented in pdf1d_kernel_pdf.

Definition at line 288 of file pdf1d_pdf.cxx.

bool pdf1d_pdf::is_valid_pdf (  )  const [virtual, inherited]

Return true if the object represents a valid PDF.

This will return false, if n_dims() is 0, for example just ofter default construction.

Reimplemented in pdf1d_mixture.

Definition at line 126 of file pdf1d_pdf.cxx.

void pdf1d_pdf::get_samples ( vnl_vector< double > &  x  )  const [inherited]

Fill x with samples drawn from distribution.

Utility function. This calls new_sampler() to do the work, then deletes the sampler again. If you intend calling this repeatedly, create a sampler yourself.

Definition at line 132 of file pdf1d_pdf.cxx.

bool pdf1d_pdf::write_plot_file ( const vcl_string &  plot_file,
double  min_x,
double  max_x,
int  n 
) const [inherited]

Write values (x,p(x)) to text file suitable for plotting.

Evaluate pdf at n points in range [min_x,max_x] and write a text file, each line of which is {x p(x)}, suitable for plotting with many graph packages

Definition at line 142 of file pdf1d_pdf.cxx.


Member Data Documentation

double pdf1d_gaussian::sd_ [private]

Definition at line 17 of file pdf1d_gaussian.h.

double pdf1d_gaussian::k_ [private]

Definition at line 18 of file pdf1d_gaussian.h.

double pdf1d_gaussian::log_k_ [private]

Definition at line 19 of file pdf1d_gaussian.h.


The documentation for this class was generated from the following files:

Generated on Sun Nov 22 06:23:39 2009 for contrib/mul/pdf1d by  doxygen 1.5.5