MathFunctions.C File Reference

#include "Util/MathFunctions.H"
#include "Util/log.H"
#include <cmath>
#include <sys/types.h>
#include <unistd.h>
Include dependency graph for MathFunctions.C:

Go to the source code of this file.

Functions

bool isFinite (const byte &arg)
 Function to check for finite value.
bool isFinite (const int16 &arg)
 Function to check for finite value.
bool isFinite (const int32 &arg)
 Function to check for finite value.
bool isFinite (const float &arg)
 Function to check for finite value.
bool isFinite (const double &arg)
 Function to check for finite value.
void initRandomNumbers ()
 Initialize random seeds from pseudo-random sources (e.g. time(), getpid()).
void initRandomNumbersZero ()
 Initialize random seeds with zero, to produce deterministic pseudo-random sequences.
double randomDouble ()
 Generate a random double in [0.0,1.0).
double randomDoubleFromNormal (const double s)
 Generate a random double from a normal distribution with mean zero and standard deviation s.
int randomUpToIncluding (const int n)
 Generate a random integer in [0,n] (i.e., including n).
int randomUpToNotIncluding (const int n)
 Generate a random integer in [0,n) (i.e., not including n).
double ran2 (int &idum)
 Random number generator from Numerical Recipes in C book.
int getIdum (const bool useRandom)
 Get a random seed for ran2.
double gasdev (int &idum)
 Randomly distributed Gaussian deviate with zero mean and unit variance.
double expdev (int &idum)
 Randomly distributed Exponential deviate.
double lngamma (double x)
 Compute log of Gamma.
double poisson (const unsigned int k, const double mu)
 Compute probability of drawing a value k from a Poisson of mean mu.
double AUC (const float *model, const float *rand, size_t sm, size_t sr, const double step)
Point2D< float > getEllipseFromCov (const Image< double > &cov)
 Convert from a covariance matrix to the major/minor axis of an ellipse.

Detailed Description

Miscellaneous math functions

Definition in file MathFunctions.C.


Function Documentation

double expdev ( int &  idum  ) 

Randomly distributed Exponential deviate.

Definition at line 204 of file MathFunctions.C.

References log(), and ran2().

double gasdev ( int &  idum  ) 

Randomly distributed Gaussian deviate with zero mean and unit variance.

Definition at line 181 of file MathFunctions.C.

References log(), ran2(), and sqrt().

Point2D<float> getEllipseFromCov ( const Image< double > &  cov  ) 

Convert from a covariance matrix to the major/minor axis of an ellipse.

Definition at line 295 of file MathFunctions.C.

References ASSERT, Image< T >::getHeight(), Image< T >::getVal(), Image< T >::getWidth(), sqrt(), and trace().

int getIdum ( const bool  useRandom = true  ) 

Get a random seed for ran2.

If useRandom is true, a random negative number will be return, otherwise a negative number that is always the same will be returned.

Definition at line 172 of file MathFunctions.C.

void initRandomNumbers (  ) 

Initialize random seeds from pseudo-random sources (e.g. time(), getpid()).

Definition at line 68 of file MathFunctions.C.

Referenced by BeeStemSim::BeeStemSim(), main(), ModelManager::paramChanged(), SceneGenerator::SceneGenerator(), Staircase::start2(), ObjRec::start2(), and submain().

void initRandomNumbersZero (  ) 

Initialize random seeds with zero, to produce deterministic pseudo-random sequences.

Definition at line 77 of file MathFunctions.C.

Referenced by ModelManager::paramChanged().

bool isFinite ( const double &  arg  ) 

Function to check for finite value.

Definition at line 51 of file MathFunctions.C.

bool isFinite ( const float &  arg  ) 

Function to check for finite value.

Definition at line 50 of file MathFunctions.C.

bool isFinite ( const int32 arg  ) 

Function to check for finite value.

Definition at line 47 of file MathFunctions.C.

bool isFinite ( const int16 arg  ) 

Function to check for finite value.

Definition at line 46 of file MathFunctions.C.

bool isFinite ( const byte arg  ) 

Function to check for finite value.

Definition at line 45 of file MathFunctions.C.

double lngamma ( double  x  ) 

Compute log of Gamma.

Definition at line 215 of file MathFunctions.C.

References D_LOG_SQRT_2_PI, and log().

Referenced by poisson().

double poisson ( const unsigned int  k,
const double  mu 
)

Compute probability of drawing a value k from a Poisson of mean mu.

Definition at line 250 of file MathFunctions.C.

References exp(), lngamma(), and log().

Referenced by SurpriseModelOD::surprise().

double ran2 ( int &  idum  ) 

Random number generator from Numerical Recipes in C book.

Long period >2x10^18 random number generator of L Ecuyer with Bays-Durham shuffle. Return a uniform deviate in the interval (0,1). Call with int variable as argument set to a negative value, and don't change this variable between calls unless you want to reseed the generator. You can get ain initial seed using the function getIdum()

Definition at line 130 of file MathFunctions.C.

Referenced by expdev(), and gasdev().

double randomDouble (  ) 

Generate a random double in [0.0,1.0).

This is a thin wrapper around drand48() or rand(), depending on which is available on the build platform.

Definition at line 86 of file MathFunctions.C.

Referenced by WTAwinner::buildFromSMcoords(), Staircase::getValues(), inplaceAddBGnoise2(), inplaceSpeckleNoise(), main(), randomDoubleFromNormal(), BPnnet::randomizeWeights(), randomUpToNotIncluding(), HippocampusI::resampleParticles(), and Beowulf::send().

double randomDoubleFromNormal ( const double  s  ) 

Generate a random double from a normal distribution with mean zero and standard deviation s.

This function call randomDouble() 12 times to sample from normal distribution

Definition at line 96 of file MathFunctions.C.

References randomDouble(), and sum().

Referenced by Objects::proposeState(), and HippocampusI::updateParticleMotion().

int randomUpToIncluding ( const int  n  ) 

Generate a random integer in [0,n] (i.e., including n).

This is a thin wrapper around lrand48() or rand(), depending on which is available on the build platform.

Definition at line 106 of file MathFunctions.C.

References randomUpToNotIncluding().

Referenced by ArmPlanner::gibbsSampling(), inplaceColorSpeckleNoise(), main(), randArmMove(), and SimulationViewerEyeRegion::start1().

int randomUpToNotIncluding ( const int  n  ) 

Generate a random integer in [0,n) (i.e., not including n).

This is a thin wrapper around lrand48() or rand(), depending on which is available on the build platform.

Definition at line 112 of file MathFunctions.C.

References randomDouble().

Referenced by PsychoDisplay::displayEyeTrackerCalibration(), ImageSpring< T >::getStats(), ImageSpring< T >::getStatsDist(), SimulationViewerCompress::getTraj(), inplaceColorSpeckleNoise(), main(), randomUpToIncluding(), randShuffle(), SimulationViewerStats::save1(), and submain().

Generated on Sun May 8 08:19:20 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3