Entropy Piano Tuner  1.1.3 (documentation not yet complete) An open-source experimental software for piano tuning by entropy minimization
MathTools Namespace Reference

## Functions

template<class T >
int roundToInteger (T x)
Round a floating point number to an integer. More...

double computeMoment (const std::vector< double > &v, const int n)
Determine the n-th moment of a distribution stored in a vector. More...

void normalize (std::vector< double > &vec)
Normalize a distribution stored in a vector. More...

double computeNorm (std::vector< double > &vec)
Compute the norm of a vector. More...

void coarseGrainSpectrum (const std::vector< double > &X, std::vector< double > &Y, std::function< double(double y)> f, double exponent=0)

double computeEntropy (const std::vector< double > &v)
Compute the Shannon entropy of a normalized probability distribution. More...

double computeRenyiEntropy (const std::vector< double > &v, const double q)
Compute the Renyi entropy of a normalized probability distribution. More...

int findMaximum (const std::vector< double > &X, int i, int j)
Find the component where the vector has its maximum. More...

int findMaximum (const std::vector< double > &X)

double findSmoothedMaximum (const std::vector< double > &x)
Use a parabola to fit the maximum. More...

double weightedArithmetricMean (const std::vector< double > &Y, size_t start=0, size_t end=std::numeric_limits< size_t >::max())
Computes the weighted arithmetric mean index of the given Y data. More...

double restrictToInterval (double x, double xmin, double xmax)
Restrict floating point value to an interval. More...

template<typename T >
void transformVector (const std::vector< T > &v, std::vector< T > &w, std::function< T(T)> f)
Map a vector to a different one by a unary map. More...

template<typename T >
std::vector< T > transformVector (const std::vector< T > &v, std::function< T(T)> f)

## Variables

const double PI = 3.14159265358979323846

const double TWO_PI = 2 * PI

const double LOG2 = 0.69314718055994530942

## Function Documentation

 void MathTools::coarseGrainSpectrum ( const std::vector< double > & X, std::vector< double > & Y, std::function< double(double y)> f, double exponent = 0 )

Map a distribution in the vector X[x] to another vector Y[y] by means of a (possibly nonlinear) function x=f(y).

It is assumed that the vector Y[y] has already a given size. If the function f maps the index range of Y to a superset of the index range of X, then the map preserves the sum over all components. Therefore, the map is suitable for mapping probability distributions. If the function f maps indices in the range of Y to a subset of the index range of X, i.e., if it does not read all of X, the corresponding probability is lost.

Parameters
 X : Given vector of floating point values (probabilities) Y : Target vector of a given size. f : Function used for coarse-graining exponent : exponent used for the mapping

Definition at line 120 of file mathtools.cpp.

Here is the call graph for this function:

 double MathTools::computeEntropy ( const std::vector< double > & v )

Compute the Shannon entropy of a normalized probability distribution.

Definition at line 56 of file mathtools.cpp.

 double MathTools::computeMoment ( const std::vector< double > & v, const int n )

Determine the n-th moment of a distribution stored in a vector.

The moments are determined with respect to the relative array index between 0 and 1

Definition at line 38 of file mathtools.cpp.

 double MathTools::computeNorm ( std::vector< double > & vec )

Compute the norm of a vector.

Definition at line 82 of file mathtools.cpp.

 double MathTools::computeRenyiEntropy ( const std::vector< double > & v, const double q )

Compute the Renyi entropy of a normalized probability distribution.

Definition at line 69 of file mathtools.cpp.

 int MathTools::findMaximum ( const std::vector< double > & X, int i, int j )

Find the component where the vector has its maximum.

Find the index of the maximum in a real-valued vector in the index range from i...j-1.

Returns
Index where the maximum is located.

Definition at line 151 of file mathtools.cpp.

 int MathTools::findMaximum ( const std::vector< double > & X )

Definition at line 159 of file mathtools.cpp.

 double MathTools::findSmoothedMaximum ( const std::vector< double > & x )

Use a parabola to fit the maximum.

Definition at line 164 of file mathtools.cpp.

 void MathTools::normalize ( std::vector< double > & vec )

Normalize a distribution stored in a vector.

Definition at line 92 of file mathtools.cpp.

Here is the call graph for this function:

 double MathTools::restrictToInterval ( double x, double xmin, double xmax )

Restrict floating point value to an interval.

Definition at line 196 of file mathtools.cpp.

template<class T >
 int MathTools::roundToInteger ( T x )

Round a floating point number to an integer.

Definition at line 43 of file mathtools.h.

template<typename T >
 void MathTools::transformVector ( const std::vector< T > & v, std::vector< T > & w, std::function< T(T)> f )

Map a vector to a different one by a unary map.

Definition at line 82 of file mathtools.h.

template<typename T >
 std::vector MathTools::transformVector ( const std::vector< T > & v, std::function< T(T)> f )

Definition at line 87 of file mathtools.h.

 double MathTools::weightedArithmetricMean ( const std::vector< double > & Y, size_t start = 0, size_t end = std::numeric_limits::max() )

Computes the weighted arithmetric mean index of the given Y data.

Definition at line 178 of file mathtools.cpp.

## Variable Documentation

 const double MathTools::LOG2 = 0.69314718055994530942

Definition at line 39 of file mathtools.h.

 const double MathTools::PI = 3.14159265358979323846

Definition at line 37 of file mathtools.h.

 const double MathTools::TWO_PI = 2 * PI

Definition at line 38 of file mathtools.h.