StochHMM  v0.34
Flexible Hidden Markov Model C++ Library and Application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Typedefs | Enumerations | Functions | Variables
StochHMM Namespace Reference

traceback_path.h More...

Classes

class  cell
class  alignment
class  Counter
class  dynamic_bitset
class  emm
class  transitionFuncParam
class  emissionFuncParam
class  ExDefSequence
class  ExDef
class  weightDef
class  model
class  models
class  Index
class  lexicalTable
 Lexical table stores the log2 probabilities for both emissions and lexical transitions. More...
class  stencil
 class stencil: contains individial model template and keeps track of coordinates for replacement More...
class  templates
 class templates: contains a map of all templates More...
struct  opt_parameters
class  opt_data
 Store the actual command line options data for each option defined by user. More...
class  options
 Parse, Store, and access commandline options data. More...
class  PWM
class  matrixPosition
struct  ppTrack
class  seqTracks
class  seqJob
class  sequence
class  sequences
class  sequenceStream
class  simpleTable
class  sparseArray
class  state
struct  stateInfo
 Contains state information for quick reference between states information. More...
class  stochTable
class  alt_simple_stochTable
class  stringList
 Stringlist is an list of strings that contains parsed comments and can be used to split string or remove whitespace from a string. More...
struct  gff_feature
class  traceback_path
class  multiTraceback
class  ambigCharacter
 Define the ambiguous characters symbol and index number for digitizing ambiguous characters in the sequence For example in DNA N = [ACGT] = [0,1,2,3]. More...
class  track
class  tracks
class  transition
 Transition information for each state. More...
class  nthScore
class  nthTrace
class  trellis
class  StateFuncs
 (**Adding in log space) More...
class  TrackFuncs
 Stores pointer to user functions used to create Real Number Tracks. More...
class  weight
 weight class contains scaling factors for external scores More...
class  weights

Typedefs

typedef std::vector
< std::vector< double > > 
mmMatrix
typedef std::vector
< std::vector< int > > 
table
typedef std::vector
< std::vector< int > > 
heatTable
typedef std::vector
< std::vector< int16_t > > 
int_2D
typedef std::vector
< std::vector< float > > 
float_2D
typedef std::vector
< std::vector< double > > 
double_2D
typedef std::vector
< std::vector< long double > > 
long_double_2D
typedef std::vector
< std::vector< std::vector
< uint16_t > > > 
int_3D
typedef std::vector
< std::vector< std::vector
< float > > > 
float_3D
typedef std::vector
< std::vector< std::vector
< double > > > 
double_3D
typedef std::vector
< std::vector< std::vector
< long double > > > 
long_double_3D
typedef double(* transitionFunc )(const std::string *, const size_t, const std::string *, const size_t)
typedef double(* emissionFunc )(const std::string *, const size_t)
 Pointer to emmission function Passed a string and position as size_t.
typedef double(* pdfFunc )(const double, const std::vector< double > *)
 Pointer to Univariate Continuous Probability Density Function.
typedef double(* multiPdfFunc )(const std::vector< double > *, const std::vector< double > *)
typedef std::vector< double > *(* pt2TrackFunc )(const std::string *)
typedef double(* pt2Attrib )(const std::string *)

Enumerations

enum  tracebackDirection { NONE, DIAGONAL, LEFT, UP }
enum  alignment_type { cGlobal, cLocal, cGlocal }
enum  countType {
  GENERAL, PERIODIC, PWM, MASK,
  NONE
}
enum  optionType {
  UNDEF_OPT, OPT_NONE, OPT_INT, OPT_DOUBLE,
  OPT_STRING, OPT_FLAG
}
enum  SeqFileFormat { FASTA, FASTQ }
 Currently only FASTA and FASTQ formats are supported. More...
enum  SeqFilesType { SINGLE_TRACK, MULTI_TRACK }
enum  transType { STANDARD, DURATION, LEXICAL }
enum  tracebackIdentifier {
  DIFF_STATE, STATE_NAME, STATE_LABEL, STATE_GFF,
  START_INIT
}
enum  combineIdentifier { FULL, STATENAME, STATELABEL, STATEGFF }
enum  trellisType { SIMPLE, STOCH, NTH }
enum  decodingType { VITERBI, FORWARD, POSTERIOR }
enum  trackType { UNDEFINED, ALPHA_NUM, REAL, EXTERNAL }
enum  unknownCharScoringType {
  DEFINED_SCORE, AVERAGE_SCORE, LOWEST_SCORE, HIGHEST_SCORE,
  NO_SCORE
}
enum  valueType {
  PROBABILITY, LOG_ODDS, COUNTS, LOG_PROB,
  PERCENTAGE
}

Functions

std::string intToBinString (uint32_t val)
size_t msb (uint32_t val)
size_t lowestBitSet (uint32_t x)
int8_t popCount (uint32_t val)
uint32_t maskLeft (uint32_t val, uint8_t pos)
uint32_t maskRight (uint32_t val, uint8_t pos)
uint32_t rol (uint32_t &val, uint8_t shift_register)
uint32_t ror (uint32_t &val, uint8_t shift_register)
template<typename T >
rol (T val, uint8_t shift_register)
 Rotate Left with carry over.
template<typename T >
ror (T val, uint8_t shift_register)
 Rotate Right with carry over.
template<typename T >
lso (T &val, uint8_t n)
template<typename T >
rso (T &val, uint8_t n)
template<typename T >
lsoso (T &val, T &old_val, uint8_t n)
template<typename T >
rsoso (T &val, T &old_val, uint8_t n)
void sBinomial (std::vector< double > &dist, int trials, double prob)
void cBinomial (std::vector< double > &dist, int trials, double prob)
void sBetaBinomial (std::vector< double > &dist, int trials, double a, double b)
void cBetaBinomial (std::vector< double > &dist, int trials, double a, double b)
void sDegenerate (std::vector< double > &dist, double value)
void cDegenerate (std::vector< double > &dist, double value)
void sUniform (std::vector< double > &dist, int lower, int upper)
void cUniform (std::vector< double > &dist, int lower, int upper)
void sHypergeometric (std::vector< double > &dist, int N, int m, int n)
void cHypergeometric (std::vector< double > &dist, int N, int m, int n)
void sCauchy (std::vector< double > &dist, double location, double scale)
double cChiSquared (double x, double df)
void sChiSquared (std::vector< double > &dist, double df)
void sExponential (std::vector< double > &dist, double lambda)
void cExponential (std::vector< double > &dist, double lambda)
void sFDistribution (std::vector< double > &dist, double dOne, double dTwo)
void cFDistribution (std::vector< double > &dist, double dOne, double dTwo)
void sGamma (std::vector< double > &dist, double shape, double scale)
void cGamma (std::vector< double > &dist, double shape, double scale)
void sGeometric (std::vector< double > &dist, double p)
void cGeometric (std::vector< double > &dist, double p)
void sLaplace (std::vector< double > &dist, double location, double scale)
void sLogNormal (std::vector< double > &dist, double location, double scale)
void sLogarithmic (std::vector< double > &dist, double prob)
void sLogistic (std::vector< double > &dist, double location, double scale)
void sMaxwellBoltzman (std::vector< double > &dist, double scale)
void sNegativeBinomial (std::vector< double > &dist, int r, double p)
void sNormal (std::vector< double > &dist, double mean, double stdev)
void sPareto (std::vector< double > &dist, double shape, double scale)
void sPoisson (std::vector< double > &dist, double lambda)
void sRayleigh (std::vector< double > &dist, double sigma)
void sTriangular (std::vector< double > &dist, int a, int b, int c)
void sUser (std::vector< double > &dist, std::vector< double > &prob_dist)
void sWeibull (std::vector< double > &dist, double shape, double scale)
void sExtremeValue (std::vector< double > &, double, double, double)
void sNonCentralF (std::vector< double > &, double, double, double)
void sNonCentralT (std::vector< double > &, double, double)
std::ostream & operator<< (std::ostream &output, const dynamic_bitset &bs)
void print_vec (std::vector< std::vector< double > > &)
 Print 2D vector to std::cout.
void sort_scores (std::vector< nthScore > &nth_scores)
 Sort the viterbi scores in the nth trellis cells.
bool _vec_sort (const nthScore &i, const nthScore &j)
double binomial_pdf (int k, int n, double p)
double beta_binomial_pdf (int k, int n, double a, double b)
double degenerate_pdf (double value, double k)
double discrete_uniform_pdf (int position, int a, int b)
double hypergeometric_pdf (int k, int n, int N, int m)
double poisson_binomial_pdf (size_t k, std::vector< double > &p)
double beta_negative_binomial_pdf (int k, int n, double a, double b)
double maxwell_boltzman_pdf (double x, double a)
double geometric_pdf (int k, double p)
double logarithmic_pdf (int k, double p)
double negative_binomial_pdf (int k, int r, double p)
double poisson_pdf (int k, double lambda)
double yule_simon_pdf (int k, double p)
double zipf_pdf (int k, int N, double s)
double zipf_mandelbrot_pdf (int k, int N, double s, double q)
double arcsine_pdf (double x)
double beta_pdf (double x, double a, double b)
double logit_normal_pdf (double x, double mu, double sigma)
double continuous_uniform_pdf (double x, double a, double b)
double kumaraswamy_pdf (double x, double a, double b)
double raised_cosine_pdf (double x, double mu, double s)
double triangular_pdf (double x, double a, double b, double c)
double truncated_normal_pdf (double x, double mu, double sd, double a, double b)
double u_quadratic_pdf (double x, double a, double b)
double wigner_semicircle_pdf (double x, double r)
double beta_prime_pdf (double x, double a, double b)
double chi_pdf (double x, double k)
double chi_squared_pdf (double x, double k)
double inverse_chi_squared_pdf (double x, double v)
double scaled_inverse_chi_squared_pdf (double x, double v, double sigma_sqrd)
double dagum_pdf (double x, double p, double a, double b)
double exponential_pdf (double x, double lambda)
double f_pdf (double x, double d1, double d2)
double fishers_z_pdf (double x, double d1, double d2)
double folded_normal_pdf (double x, double mu, double sigma_sqrd)
double frechet_pdf (double x, double alpha, double s, double m)
double gamma_pdf (double x, double alpha, double beta)
double inv_gamma_pdf (double x, double alpha, double beta)
double half_normal_pdf (double x, double sigma)
double inv_gaussian_pdf (double x, double mu, double lambda)
double levy_pdf (double x, double mu, double scale)
double log_cauchy_pdf (double x, double mu, double sigma)
double log_laplace_pdf (double x, double mu, double b)
double log_logistic_pdf (double x, double a, double b)
double log_normal_pdf (double x, double mu, double sigma_sqrd)
double pareto_pdf (double x, double alpha, double x_m)
double nakagami_pdf (double x, double mu, double w)
double rayleigh_pdf (double x, double sigma)
double gumbel_type_two_pdf (double x, double a, double b)
double weibull_distribution (double x, double lambda, double k)
double cauchy_pdf (double x, double x_o, double gamma)
double gumbel_pdf (double x, double mu, double beta)
double generalized_normal_pdf (double x, double mu, double alpha, double beta)
double hyperbolic_secant_pdf (double x)
double laplace_pdf (double x, double mu, double b)
double logistic_pdf (double x, double mu, double s)
double standard_normal_pdf (double x)
double normal_pdf (double x, double mu, double sigma)
double students_t_pdf (double x, double v)
double gumbel_type_one_pdf (double x, double a, double b)
double generalized_extreme_value_pdf (double x, double mu, double sigma, double xi)
double generalized_pareto_pdf (double x, double mu, double sigma, double xi)
double dirichlet_pdf (const std::vector< double > &x, const std::vector< double > &alpha)
double multivariate_ewens_pdf (const std::vector< double > &x, const double theta)
double binomial_pdf (int k, std::vector< double > param)
double poisson_binomial_pdf (int k, std::vector< double > &p)
double beta_pdf (double x, std::vector< double > param)
double binomial_pdf (const double k, const std::vector< double > *param)
double beta_binomial_pdf (const double k, const std::vector< double > *param)
double degenerate_pdf (const double value, const std::vector< double > *param)
double discrete_uniform_pdf (const double position, const std::vector< double > *param)
double hypergeometric_pdf (const double k, const std::vector< double > *param)
double beta_negative_binomial_pdf (const double k, const std::vector< double > *param)
double maxwell_boltzman_pdf (const double x, const std::vector< double > *param)
double geometric_pdf (const double k, const std::vector< double > *param)
double logarithmic_pdf (const double k, const std::vector< double > *param)
double negative_binomial_pdf (const double k, const std::vector< double > *param)
double poisson_pdf (const double k, const std::vector< double > *param)
double yule_simon_pdf (const double k, const std::vector< double > *param)
double zipf_pdf (const double k, const std::vector< double > *param)
double zipf_mandelbrot_pdf (const double k, const std::vector< double > *param)
double arcsine_pdf (const double x, const std::vector< double > *param)
double beta_pdf (const double x, const std::vector< double > *param)
double logit_normal_pdf (const double x, const std::vector< double > *param)
double continuous_uniform_pdf (const double x, const std::vector< double > *param)
double kumaraswamy_pdf (const double x, const std::vector< double > *param)
double raised_cosine_pdf (const double x, const std::vector< double > *param)
double triangular_pdf (const double x, const std::vector< double > *param)
double truncated_normal_pdf (const double x, const std::vector< double > *param)
double u_quadratic_pdf (const double x, const std::vector< double > *param)
double wigner_semicircle_pdf (const double x, const std::vector< double > *param)
double beta_prime_pdf (const double x, const std::vector< double > *param)
double chi_pdf (const double x, const std::vector< double > *param)
double chi_squared_pdf (const double x, const std::vector< double > *param)
double inverse_chi_squared_pdf (const double x, const std::vector< double > *param)
double scaled_inverse_chi_squared_pdf (const double x, const std::vector< double > *param)
double dagum_pdf (const double x, const std::vector< double > *param)
double exponential_pdf (const double x, const std::vector< double > *param)
double f_pdf (const double x, const std::vector< double > *param)
double fishers_z_pdf (const double x, const std::vector< double > *param)
double folded_normal_pdf (const double x, const std::vector< double > *param)
double frechet_pdf (const double x, const std::vector< double > *param)
double gamma_pdf (const double x, const std::vector< double > *param)
double inv_gamma_pdf (const double x, const std::vector< double > *param)
double half_normal_pdf (const double x, const std::vector< double > *param)
double inv_gaussian_pdf (const double x, const std::vector< double > *param)
double levy_pdf (const double x, const std::vector< double > *param)
double log_cauchy_pdf (const double x, const std::vector< double > *param)
double log_laplace_pdf (const double x, const std::vector< double > *param)
double log_logistic_pdf (const double x, const std::vector< double > *param)
double log_normal_pdf (const double x, const std::vector< double > *param)
double pareto_pdf (const double x, const std::vector< double > *param)
double nakagami_pdf (const double x, const std::vector< double > *param)
double rayleigh_pdf (const double x, const std::vector< double > *param)
double gumbel_type_two_pdf (const double x, const std::vector< double > *param)
double weibull_distribution (const double x, const std::vector< double > *param)
double cauchy_pdf (const double x, const std::vector< double > *param)
double gumbel_pdf (const double x, const std::vector< double > *param)
double generalized_normal_pdf (const double x, const std::vector< double > *param)
double hyperbolic_secant_pdf (const double x, const std::vector< double > *param)
double laplace_pdf (const double x, const std::vector< double > *param)
double logistic_pdf (const double x, const std::vector< double > *param)
double standard_normal_pdf (const double x, const std::vector< double > *param)
double normal_pdf (const double x, const std::vector< double > *param)
double students_t_pdf (const double x, const std::vector< double > *param)
double gumbel_type_one_pdf (const double x, const std::vector< double > *param)
double generalized_extreme_value_pdf (const double x, const std::vector< double > *param)
double generalized_pareto_pdf (const double x, const std::vector< double > *param)
double dirichlet_multi_pdf (const std::vector< double > *x, const std::vector< double > *param)
double ewens_multi_pdf (const std::vector< double > *x, const std::vector< double > *param)
sequence random_sequence (std::vector< double > &freq, size_t length, track *tr)
template<class T >
min (std::vector< T > &set)
template<class T >
max (std::vector< T > &set)
template<class T >
construct_histogram (std::vector< T > &set, int N_bins)
template<class T >
smooth_histogram (std::vector< T > histo, int intervals, int window_size, int iterations)
float entropy (std::vector< float > &set)
 Shannon's Entropy in log(2) space.
float rel_entropy (std::vector< float > &set, std::vector< float > &set2)
double _integrate (double(*funct)(double, std::vector< double >), double upper, double lower, std::vector< double > param)
double integrate (double(*funct)(double, std::vector< double >), double lower, double upper, std::vector< double > param, double max_error=0.001, double sum=0)
double simpson (double(*funct)(double, double, double), double alpha, double beta, double lower, double upper)
double adapt_simpson (double(*funct)(double, double, double), double alpha, double beta, double lower, double upper, double max_error, double sum)
float discrete_uniform_cdf (int a, int b, int position)
float bin_coef (int n, int k)
float binomial_pdf (int k, int n, float p)
float binomial_pdf (int k, std::vector< float > param)
float binomial_cdf (int k, int n, float p)
double hypergeometric_cdf (int n, int N, int m, int k)
double gamma_func (double x)
double gamma_pdf (double x, std::vector< double > param)
double gamma_cdf (double x, double alpha, double beta)
double chi2_pdf (double x, double df)
double chi2_cdf (double x, double df)
double beta_cdf (double x, double alpha, double beta)
double expon_pdf (double x, double beta)
double expon_cdf (double x, double beta)
float summation (float(*funct)(int, std::vector< float >), int lower, int upper, std::vector< float > param)
double multinomial_pdf (std::vector< int > r, int n, std::vector< double > p)
double _low_igamma (double x, std::vector< double > param)
double low_igamma (double x, double alpha)
double upper_igamma (double x, double alpha)
double erf (double x)
double std_normal_cdf (double x)
double binomial_cdf (double)
double hypergeometric_cdf (double)
double poisson_binomial_cdf (double)
double degenerate_distribution (double)
double beta_binomial_cdf (double)
double boltzman_cdf (double)
double extended_negative_binomial_cdf (double)
double geometric_cdf (double)
double logarithmic_cdf (double)
double negative_binomial_cdf (double)
double parabolic_fractal_cdf (double)
double poisson_cdf (double)
double skellam_cdf (double)
double yule_simon_cdf (double)
double zeta (double)
float continuous_uniform_cdf (float, float, float)
double beta_prime_cdf (double)
double chi_cdf (double)
double noncentral_chi_cdf (double)
double chi_square_cdf (double)
double exponential_cdf (double)
double F_cdf (double)
double gamma_cdf (double)
double fisher_z_cdf (double)
double folded_normal_distribution (double)
double half_normal_distribution (double)
double hotelling_t_square_cdf (double)
double inverse_gaussian_cdf (double)
double log_logistic_cdf (double)
double log_normal_cdf (double)
double pareto_cdf (double)
template<class T >
smooth_histogram (std::vector< T > &, int, int, int)
double simpson (double(*funct)(double, std::vector< double >), double alpha, double beta, double lower, double upper)
void generateUnknownIndices (std::vector< size_t > &results, size_t alphabetSize, size_t order, size_t value)
double interpolate (std::pair< double, double > &a, std::pair< double, double > &b, double &cx)
 Interpolates the y value given cx and two surrounding points on either side a and b.
double extrapolate (std::pair< double, double > &a, std::pair< double, double > &b, double &cx)
 Extrapolates the Y value of point given by cx and two previous points.
double entropy (std::vector< double > &set)
double rel_entropy (std::vector< double > &set, std::vector< double > &set2)
double _integrate (double(*funct)(double, std::vector< double > &), double upper, double lower, std::vector< double > &param)
double integrate (double(*funct)(double, std::vector< double > &), double lower, double upper, std::vector< double > &param, double max_error=0.000001, double sum=0)
double summation (double(*funct)(int, std::vector< double >), int lower, int upper, std::vector< double > param)
double igamma_upper (double s, double x)
double igamma_lower (double a, double x)
 http://wwwC/.rskey.org/CMS/index.php/the-library/11
double rgammap (double s, double x)
double rgammaq (double s, double x)
double beta (double a, double b)
double ibeta (double x, double a, double b)
float betaPDF (float x, float a, float b)
double ribeta (double x, double a, double b)
double factorial (double x)
double bin_coef (double n, double r)
template<typename T >
integerPower (T base, T exponent)
template<typename T >
addLog (T first, T second)
template<typename T >
void addVectorCombinatorial (std::vector< T > &result, std::vector< T > &lhs, std::vector< T > &rhs)
template<typename T >
void multiplyVectorCombinatorial (std::vector< T > &result, std::vector< T > &lhs, std::vector< T > &rhs)
template<typename T >
void addValueToVector (std::vector< T > &vec, T value)
template<typename T >
void multiplyValueToVector (std::vector< T > &vec, T value)
template<typename T >
void divideValueToVector (std::vector< T > &vec, T value)
template<class T >
sumVector (std::vector< T > &data)
 Sum the vector and return the sum.
template<class T >
sumVector (const std::vector< T > &data)
template<class T >
productVector (std::vector< T > &data)
 Multiply terms in vector and return the product.
template<typename T >
minVector (std::vector< T > &data)
template<typename T >
maxVector (std::vector< T > &data)
template<typename T >
avgVector (std::vector< T > &data)
template<typename T >
void logVector (std::vector< T > &data)
template<typename T >
void expVector (std::vector< T > &data)
template<typename T >
avgLogVector (std::vector< T > &data)
template<typename T >
void probVector (std::vector< T > &data)
template<typename T >
void addVector (std::vector< T > &lhs, std::vector< T > &rhs)
template<typename T >
void logProbVector (std::vector< T > &data)
double simpson (double(*funct)(double, std::vector< double > &), double alpha, double beta, double lower, double upper)
double summation (double(*funct)(int, std::vector< double > &), int, int, std::vector< double > &)
double _igamma_lower (double, std::vector< double > &)
double _ibeta (double, std::vector< double > &)
double logit (double x)
std::string parseComment (std::string &txt, char commentChar)
 Find first comment character and then return everything following the character.
void clear_whitespace (std::string &input, std::string white)
void removeLeadingWS (std::string &txt, const std::string &ws)
void getKeyValue (std::string &txt, std::string &key, std::string &value)
stringListsplitString (const std::string &txt, const std::string &delimiters)
 Splits string using delimiters and return stringList.
void replaceChar (std::string &txt, char ch, char replaceCh)
std::string join (std::vector< int > &input, char c)
std::string join (std::vector< size_t > &input, char c)
std::string int_to_string (int input)
std::string int_to_string (size_t input)
std::string double_to_string (double input)
std::string double_to_string (float input)
bool stringToInt (std::string &txt, int &val)
bool stringToInt (std::string &txt, size_t &val)
bool stringToDouble (std::string &txt, double &val)
std::string join (std::vector< short > &input, char c)
std::string join (std::vector< double > &input, char c)
std::string join (std::vector< std::string > &input, char c)
void split_line (std::vector< std::string > &line, std::string &input)
stringList extractTag (std::string &txt)
std::pair< size_t, size_t > balanced_brackets (const std::string &text, const std::string &brackets, size_t offset)
std::pair< size_t, size_t > balanced_brackets (const std::string &text, const std::string &brackets)
bool isNumeric (const std::string &str)
std::string slurpFile (std::string &file)
bool sortTBVec (std::map< traceback_path, int >::iterator lhs, std::map< traceback_path, int >::iterator rhs)
bool compXval (const std::pair< double, double > &a, const std::pair< double, double > &b)

Variables

bool quiet
int maximum = 1000000
const uint32_t POWER [32][128]
int WID = 80

Detailed Description

traceback_path.h

transitions.h


Typedef Documentation

typedef std::vector<std::vector<double> > StochHMM::double_2D

Definition at line 51 of file trellis.h.

typedef std::vector<std::vector<std::vector<double> > > StochHMM::double_3D

Definition at line 56 of file trellis.h.

typedef double(* StochHMM::emissionFunc)(const std::string *, const size_t)

Pointer to emmission function Passed a string and position as size_t.

emissionFunc

Definition at line 46 of file userFunctions.h.

typedef std::vector<std::vector<float> > StochHMM::float_2D

Definition at line 50 of file trellis.h.

typedef std::vector<std::vector<std::vector<float> > > StochHMM::float_3D

Definition at line 55 of file trellis.h.

typedef std::vector<std::vector<int> > StochHMM::heatTable

Definition at line 165 of file traceback_path.h.

typedef std::vector<std::vector<int16_t> > StochHMM::int_2D

Definition at line 49 of file trellis.h.

typedef std::vector<std::vector<std::vector<uint16_t> > > StochHMM::int_3D

Definition at line 54 of file trellis.h.

typedef std::vector<std::vector<long double> > StochHMM::long_double_2D

Definition at line 52 of file trellis.h.

typedef std::vector<std::vector<std::vector<long double> > > StochHMM::long_double_3D

Definition at line 57 of file trellis.h.

typedef std::vector<std::vector<double> > StochHMM::mmMatrix

Definition at line 44 of file alignment.h.

StochHMM::multiPdfFunc

Pointer to function that takes reference to array (variables) and pointer to vector that contains multivariate function paramenters.

Definition at line 57 of file userFunctions.h.

StochHMM::pdfFunc

Pointer to Univariate Continuous Probability Density Function.

Parameters:
[in]doubleGiven value
[in]std::vector<double>*Paramenters for PDF

Definition at line 52 of file userFunctions.h.

typedef double(* StochHMM::pt2Attrib)(const std::string *)

Definition at line 64 of file userFunctions.h.

typedef std::vector<double>*(* StochHMM::pt2TrackFunc)(const std::string *)

Definition at line 61 of file userFunctions.h.

typedef std::vector<std::vector<int> > StochHMM::table

Definition at line 43 of file Counter.h.

typedef double(* StochHMM::transitionFunc)(const std::string *, const size_t, const std::string *, const size_t)

Definition at line 41 of file userFunctions.h.


Enumeration Type Documentation

Enumerator:
cGlobal 
cLocal 
cGlocal 

Definition at line 25 of file alignment.h.

enum combineIdentifier { FULL , STATENAME , STATELABEL , STATEGFF}; *Describes how a traceback will be processed Types of Combine Identifiers FULL = No traceback editing will occur STATENAME = Edit out all the states that aren't of given State Name STATELABEL= Edit out all the states that aren't of given State Label STATEGFF = Edit out all the states that aren't of given GFF Tag

Enumerator:
FULL 
STATENAME 
STATELABEL 
STATEGFF 

Definition at line 62 of file stochTypes.h.

Enumerator:
GENERAL 
PERIODIC 
PWM 
MASK 
NONE 

Definition at line 45 of file Counter.h.

{VITERBI, POSTERIOR}; *Type of decoding to perform. VITERBI = Traceback performed using viterbi value FORWARD = Traceback performed using stochastic forward value POSTERIOR = Traceback performed using posterior value

Enumerator:
VITERBI 
FORWARD 
POSTERIOR 

Definition at line 78 of file stochTypes.h.

Enumerator:
UNDEF_OPT 
OPT_NONE 
OPT_INT 
OPT_DOUBLE 
OPT_STRING 
OPT_FLAG 

Definition at line 25 of file options.h.

Currently only FASTA and FASTQ formats are supported.

*File format of the sequences

Enumerator:
FASTA 
FASTQ 

Definition at line 60 of file seqTracks.h.

SINGLE means that only a single sequence is required (using single track) *MULTI means that multiple sequences are required from multiple tracks

*Sequence files have single track or multiple track sequences per file

Enumerator:
SINGLE_TRACK 
MULTI_TRACK 

Definition at line 66 of file seqTracks.h.

Enumerator:
NONE 
DIAGONAL 
LEFT 
UP 

Definition at line 24 of file alignment.h.

{ DIFF_STATE , STATE_NAME , STATE_LABEL , STATE_GFF , START_INIT }; Traceback identifier describe how stochHMM will traceback when using duration dependent distributions Types of Tracebacks DIFF_STATE = Traceback current state until a different state is encountered STATE_NAME = Traceback until STATE_NAME changes from current state, essentially the same as DIFF_STATE STATE_LABEL = Traceback until a State with a different label is encountered STATE_GFF = Traceback until a State witha a different GFF tag is encountered START_INIT = Traceback until the start of the sequence

Enumerator:
DIFF_STATE 
STATE_NAME 
STATE_LABEL 
STATE_GFF 
START_INIT 

Definition at line 52 of file stochTypes.h.

Track types UNDEFINED = NOT DEFINED BY USER ALPHA_NUM = Alphabet is letter or word based (discrete) REAL = Real number values (continuous) EXTERNAL = ???

Enumerator:
UNDEFINED 
ALPHA_NUM 
REAL 
EXTERNAL 

Definition at line 86 of file stochTypes.h.

Enumerator:
STANDARD 
DURATION 
LEXICAL 

Definition at line 41 of file stochTypes.h.

{SIMPLE, STOCH, NTH}; *Defines what type of trellis cells to use *Types of trellis SIMPLE = Trellis will only contain single viterbi, forward, and backward values STOCH = Trellis will contain multiple viterbi,forward,backward values and traceback probabilities for stochastic tracebacks NTH = Trellis will contain N viterbi values for top N tracebacks

Enumerator:
SIMPLE 
STOCH 
NTH 

Definition at line 71 of file stochTypes.h.

enum unknownCharScoringType { DEFINED_SCORE, AVERAGE_SCORE, LOWEST_SCORE, HIGHEST_SCORE, NO_SCORE}; How to score unknown or ambiguous characters when encountered in emission or transition Scoring types: DEFINED_SCORE = user-defined score AVERAGE_SCORE = average of all possible scores LOWEST_SCORE = lowest of the possible scores HIGHEST_SCORE = highest of the possible scores NO_SCORE = No score will be defined (Produces error if unknown alphabet encountered)

Enumerator:
DEFINED_SCORE 
AVERAGE_SCORE 
LOWEST_SCORE 
HIGHEST_SCORE 
NO_SCORE 

Definition at line 99 of file stochTypes.h.

Value types that are provided by user *PROBABILITY = basic probability between [0,1] *LOG_ODDS = log odds score *COUNTS = word counts *LOG_PROG = log2 value of probability *PERCENTAGE = [0,100] or 100*Probability

Enumerator:
PROBABILITY 
LOG_ODDS 
COUNTS 
LOG_PROB 
PERCENTAGE 

Definition at line 109 of file stochTypes.h.


Function Documentation

double StochHMM::_ibeta ( double  ,
std::vector< double > &   
)
double StochHMM::_igamma_lower ( double  ,
std::vector< double > &   
)
double StochHMM::_integrate ( double(*)(double, std::vector< double > &)  funct,
double  upper,
double  lower,
std::vector< double > &  param 
)

Definition at line 107 of file stochMath.cpp.

{
double mid=(lower+upper)/2.0;
double h3=fabs(upper-lower)/6.0;
return h3*(funct(lower,param)+4*funct(mid,param)+funct(upper,param));
}
double StochHMM::_integrate ( double(*)(double, std::vector< double >)  funct,
double  upper,
double  lower,
std::vector< double >  param 
)

Definition at line 116 of file statistics.cpp.

Referenced by integrate().

{
double mid=(lower+upper)/2.0;
double h3=fabs(upper-lower)/6.0;
return h3*(funct(lower,param)+4*funct(mid,param)+funct(upper,param));
}
double StochHMM::_low_igamma ( double  x,
std::vector< double >  param 
)

Definition at line 338 of file statistics.cpp.

Referenced by low_igamma().

{
double value=param[0];
return (pow(x,value-1)*exp(-x));
}
bool StochHMM::_vec_sort ( const nthScore &  i,
const nthScore &  j 
)

Definition at line 23 of file nth_best.cpp.

References StochHMM::nthScore::score.

Referenced by sort_scores().

{
return (i.score > j.score);
}
double StochHMM::adapt_simpson ( double(*)(double, double, double)  funct,
double  alpha,
double  beta,
double  lower,
double  upper,
double  max_error,
double  sum 
)

Definition at line 141 of file statistics.cpp.

References simpson().

{
double mid=(upper+lower)/2.0;
double left=simpson(funct,alpha,beta,lower, mid);
double right=simpson(funct,alpha,beta,mid,upper);
if (fabs(left+right-sum)<=15*max_error){
return left+right +(left+right-sum)/15;
}
return adapt_simpson(funct,alpha,beta,lower,mid,max_error/2,left) + adapt_simpson(funct,alpha,beta,mid,upper,max_error/2,right);
}
template<typename T >
T StochHMM::addLog ( first,
second 
)

Takes two logd values and adds them together

Parameters:
firstlog'd Double value
secondlog'd Double value
Returns:
Log'd sum of two values

Definition at line 179 of file stochMath.h.

Referenced by StochHMM::stochTable::finalize(), StochHMM::alt_simple_stochTable::finalize(), StochHMM::trellis::naive_backward(), StochHMM::trellis::naive_baum_welch(), StochHMM::trellis::naive_forward(), StochHMM::trellis::naive_stochastic_forward(), StochHMM::trellis::simple_backward(), StochHMM::trellis::simple_forward(), StochHMM::trellis::simple_posterior(), StochHMM::trellis::simple_stochastic_forward(), and StochHMM::trellis::update_transitions().

{
if (first==-INFINITY){
return second;
}
else if (second==-INFINITY){
return first;
}
else if (first>second){
return first+log(1+exp(second-first));
}
else{
return second+log(1+exp(first-second));
}
}
template<typename T >
void StochHMM::addValueToVector ( std::vector< T > &  vec,
value 
)

Definition at line 272 of file stochMath.h.

Referenced by StochHMM::Index::operator+(), and StochHMM::Index::operator+=().

{
for(size_t i=0;i<vec.size();i++){
vec[i]+=value;
}
return;
}
template<typename T >
void StochHMM::addVector ( std::vector< T > &  lhs,
std::vector< T > &  rhs 
)

Definition at line 434 of file stochMath.h.

{
transform(lhs.begin(), lhs.end(), rhs.begin(), lhs.begin(), std::plus<T>());
return;
}
template<typename T >
void StochHMM::addVectorCombinatorial ( std::vector< T > &  result,
std::vector< T > &  lhs,
std::vector< T > &  rhs 
)

Definition at line 209 of file stochMath.h.

Referenced by StochHMM::Index::operator+(), and StochHMM::Index::operator+=().

{
if (result.size()>0){
result.clear();
}
//If either vector is empty then return copy of the other
if (lhs.size()==0){
result.assign(rhs.begin(),rhs.end());
return;
}
else if (rhs.size()==0){
result.assign(lhs.begin(),lhs.end());
return;
}
for(size_t i=0;i<lhs.size();i++){
for(size_t j=0;j<rhs.size();j++){
result.push_back(lhs[i]+rhs[j]);
}
}
return;
}
template<typename T >
T StochHMM::avgLogVector ( std::vector< T > &  data)

Definition at line 409 of file stochMath.h.

References expVector(), and sumVector().

{
expVector(data);
return log(sumVector(data) / T(data.size()));
}
template<typename T >
T StochHMM::avgVector ( std::vector< T > &  data)

Definition at line 375 of file stochMath.h.

References sumVector().

{
return sumVector(data) / T(data.size());
}
std::pair< size_t, size_t > StochHMM::balanced_brackets ( const std::string &  text,
const std::string &  brackets,
size_t  offset 
)

Returns a pair of size_t values that describe the coordinates of between brackets

Parameters:
textString to use to search for brackets
bracketsString of length two containing opening and closing bracket
offsetOffset of where to start searching for balanced brackets

Definition at line 758 of file text.cpp.

Referenced by balanced_brackets(), and extractTag().

{
char opening = brackets[0];
char closing = brackets[1];
int currentTotal(0);
size_t start;
size_t found;
found=text.find_first_of(opening,offset);
if (found!=std::string::npos){
start=found;
currentTotal++;
}
else{
return std::make_pair(0,0);
}
while(currentTotal!=0){
found++;
found=text.find_first_of(brackets,found);
if (found!=std::string::npos){
if (text[found]==opening){
currentTotal++;
}
else if (text[found]==closing){
currentTotal--;
}
}
else{
return std::make_pair(0,0);
}
}
return std::make_pair(start,found);
}
std::pair< size_t, size_t > StochHMM::balanced_brackets ( const std::string &  text,
const std::string &  brackets 
)

Returns a pair of size_t values that describe the coordinates of between brackets from start of the string

Parameters:
textString to use to search for brackets
bracketsString of length two containing opening and closing bracket

Definition at line 800 of file text.cpp.

References balanced_brackets().

{
return balanced_brackets(text,brackets,0);
}
double StochHMM::beta ( double  a,
double  b 
)

Definition at line 192 of file stochMath.cpp.

Referenced by beta_binomial_pdf(), beta_cdf(), beta_prime_pdf(), betaPDF(), cBetaBinomial(), f_pdf(), fishers_z_pdf(), gamma_cdf(), ribeta(), sBetaBinomial(), truncated_normal_pdf(), u_quadratic_pdf(), and yule_simon_pdf().

{
double value=(tgamma(a)*tgamma(b))/tgamma(a+b);
return value;
}
double StochHMM::beta_binomial_cdf ( double  )
double StochHMM::beta_cdf ( double  x,
double  alpha,
double  beta 
)

Definition at line 284 of file statistics.cpp.

References beta(), beta_pdf(), and integrate().

Referenced by truncated_normal_pdf().

{
std::vector<double> parameters (2,0.0);
parameters[0]=alpha;
parameters[1]=beta;
return integrate(beta_pdf, 0.0, x,parameters);
}
double StochHMM::beta_prime_cdf ( double  )
float StochHMM::betaPDF ( float  x,
float  a,
float  b 
)

Beta probability distribution function *param x Value 0<x<1 *param a Shape parameter a>0 *param b Shape parameter b>0

Definition at line 207 of file stochMath.cpp.

References beta().

Referenced by beta_pdf(), and ibeta().

{
float constant = 1/beta(a,b);
constant*=pow(x,a-1) * pow(1-x,b-1);
return constant;
}
int StochHMM::bin_coef ( int  n,
int  k 
)

Binomial coefficient *number of combinations possible given k unordered outcomes from n possibilities *param n number of items *param k number in set

Definition at line 181 of file statistics.cpp.

Referenced by beta_binomial_pdf(), beta_negative_binomial_pdf(), binomial_pdf(), cBetaBinomial(), cBinomial(), cHypergeometric(), hypergeometric_cdf(), hypergeometric_pdf(), negative_binomial_pdf(), sBetaBinomial(), sBinomial(), and sHypergeometric().

{
float c=0;
for(int i=k+1;i<=n;i++) {c+=log(i);}
for(int j=1;j<=(n-k);j++) {c-=log(j);}
return exp(c);
}
double StochHMM::bin_coef ( double  n,
double  r 
)

Definition at line 242 of file stochMath.cpp.

{
double c=0;
for(int i=r+1;i<=n;i++) {c+=log(i);}
for(int j=1;j<=(n-r);j++) {c-=log(j);}
return exp(c);
}
double StochHMM::binomial_cdf ( double  )
float StochHMM::binomial_cdf ( int  k,
int  n,
float  p 
)

Binomial Cumulative Distribution Function *param k Number of successes *param n Number of trials *param p Probability of success *If we can get an incomplete beta function. We can update this function and

Definition at line 210 of file statistics.cpp.

References binomial_pdf(), and summation().

{
std::vector<float> param (2,0.0);
param[0]=n;
param[1]=p;
return summation(binomial_pdf,0,k,param);
}
float StochHMM::binomial_pdf ( int  k,
int  n,
float  p 
)

Binomial probability mass function *param k Number of successes *param n Number of trials *param p Probability of success

Definition at line 192 of file statistics.cpp.

References bin_coef().

{
return bin_coef(n,k)*pow(p,k)*pow(1-p,n-k);
}
float StochHMM::binomial_pdf ( int  k,
std::vector< float >  param 
)

Binomial probaility mass function *param k Number of successes *param param std::vector<float> (n=number of trials, p=probability of success)

Definition at line 199 of file statistics.cpp.

References binomial_pdf().

{
return binomial_pdf(k, param[0],param[1]);
}
double StochHMM::boltzman_cdf ( double  )
void StochHMM::cBetaBinomial ( std::vector< double > &  dist,
int  trials,
double  a,
double  b 
)

BetaBinomial Cumulative Distribution *a href = "http://en.wikipedia.org/wiki/Beta-binomial_model">

Parameters:
[out]dist
trialsNumber of trials
aalpha
bbeta

Definition at line 101 of file distributions.cpp.

References beta(), bin_coef(), and maximum.

{
double cdf = 0;
for (int i=1; i<maximum;i++){
double newAlpha = (double) i + a;
double newBeta = (double)(trials-i) + b;
double pmf = bin_coef(trials,i) * (beta(newAlpha,newBeta)/ beta(a,b));
cdf+=pmf;
double val=cdf;
if (val>=1.0){
dist.push_back(1.0);
break;
}
else{
dist.push_back(val);
}
}
return;
}
void StochHMM::cBinomial ( std::vector< double > &  dist,
int  trials,
double  prob 
)

Binomial Cumulative Distribution

Parameters:
[out]dist
trialsNumber of trials in experiment
probProbability of success

Definition at line 48 of file distributions.cpp.

References bin_coef(), and maximum.

{
//http://en.wikipedia.org/wiki/Binomial_distribution
double cdf=0;
for (int i=1; i<maximum;i++){
double pmf=bin_coef(trials,i)*pow(prob,i)*pow(1-prob,trials-i);
cdf+=pmf;
double val=cdf;
if (val>=1.0){
dist.push_back(1.0);
break;
}
else{
dist.push_back(val);
}
}
return;
}
double StochHMM::cChiSquared ( double  x,
double  df 
)

CDF of Chi-Squared Distribution

Parameters:
xChi-Square Value
dfDegrees of freedom
Returns:
double Value of CDF at x

Definition at line 252 of file distributions.cpp.

References igamma_lower().

{
double val = 1.0/tgamma(df/2.0);
double div = igamma_lower(df/2.0,x/2.0);
return val*div;
}
void StochHMM::cDegenerate ( std::vector< double > &  dist,
double  value 
)

Degenerate Cumulative Distribution *Support consists of only one value

Parameters:
[out]dist
value*a href = "http://en.wikipedia.org/wiki/Degenerate_distribution">

Definition at line 141 of file distributions.cpp.

{
for (int i=0;i<value;i++){
dist.push_back(0);
}
dist.push_back(1);
return;
}
void StochHMM::cExponential ( std::vector< double > &  dist,
double  lambda 
)

CDF Exponential Distribution

Parameters:
[out]dist
lambdaValue of lambda to use *a href = "http://en.wikipedia.org/wiki/Exponential_distribution">

Definition at line 309 of file distributions.cpp.

References maximum.

{
for (int i=0; i<maximum;i++){
double val=1-exp(-1*lambda*i);
if (val==0){
break;
}
else{
dist.push_back(val);
}
}
return;
}
void StochHMM::cFDistribution ( std::vector< double > &  dist,
double  dOne,
double  dTwo 
)

Definition at line 372 of file distributions.cpp.

References maximum, and ribeta().

{
//http://en.wikipedia.org/wiki/F_distribution
for (int i=0;i<maximum;i++){
double val=ribeta((dOne*i)/((dOne*i)+dTwo), dOne/2, dTwo/2);
if (val==1){
dist.push_back(1.0);
break;
}
else{
dist.push_back(val);
}
}
return;
}
void StochHMM::cGamma ( std::vector< double > &  dist,
double  shape,
double  scale 
)

Definition at line 407 of file distributions.cpp.

References igamma_lower(), and maximum.

{
//http://en.wikipedia.org/wiki/Gamma_distribution
for (int i=0;i<maximum;i++){
double val=igamma_lower(shape, i/scale)/tgamma(shape);
if (val==1){
dist.push_back(1.0);
break;
}
else{
dist.push_back(val);
}
}
return;
}
void StochHMM::cGeometric ( std::vector< double > &  dist,
double  p 
)

Definition at line 438 of file distributions.cpp.

References maximum.

{
//http://en.wikipedia.org/wiki/Geometric_distribution
for (int i=0;i<maximum;i++){
double val=1-pow((1-p),i+1);
if (val==1){
dist.push_back(1.0);
break;
}
else{
dist.push_back(val);
}
}
return;
}
double StochHMM::chi2_cdf ( double  x,
double  df 
)

Definition at line 272 of file statistics.cpp.

References gamma_cdf().

{
return gamma_cdf(x,df/2.0,0.5);
}
double StochHMM::chi2_pdf ( double  x,
double  df 
)

Definition at line 268 of file statistics.cpp.

References gamma_pdf().

{
return gamma_pdf(x,df/2.0,0.5);
}
double StochHMM::chi_cdf ( double  )
double StochHMM::chi_square_cdf ( double  )
void StochHMM::cHypergeometric ( std::vector< double > &  dist,
int  N,
int  m,
int  n 
)

CDF Hypergeometric Distribution

Parameters:
[out]dist
NPopulation Size
mNumber of successes
nNumber of draws

Definition at line 212 of file distributions.cpp.

References bin_coef(), and maximum.

{
//http://en.wikipedia.org/wiki/Hypergeometric_distribution
double cdf=0;
for( int k=0;k<maximum;k++){ //k = number of successes
double pmf=((double)bin_coef(m,k) * (double)bin_coef(N-m,n-k))/(double) bin_coef(N,n);
cdf+=pmf;
double val=cdf;
if (val>=1){
dist.push_back(1.0);
break;
}
else{
dist.push_back(val);
}
}
return;
}
void StochHMM::clear_whitespace ( std::string &  input,
std::string  white 
)

Given a string, and a white space character, it will remove all the whitespace characters from the string

Parameters:
inputString to remove whitespace from
whiteString of whitespace characters to remove

Definition at line 435 of file text.cpp.

Referenced by StochHMM::sequence::_digitize(), StochHMM::PWM::_getOrderedPositionNames(), StochHMM::model::_getOrderedStateNames(), StochHMM::state::_parseHeader(), StochHMM::PWM::_parseSpacer(), StochHMM::state::_parseTransition(), StochHMM::model::_processTemplateState(), StochHMM::track::_splitAmbiguousList(), StochHMM::PWM::_splitPositions(), StochHMM::model::_splitStates(), StochHMM::sequence::getMaskedFasta(), StochHMM::matrixPosition::parse(), StochHMM::weight::parse(), and StochHMM::stringList::processString().

{
size_t found;
found=input.find_first_of(white);
//found=input.find_first_of("\t\n ");
while(found!=std::string::npos){
input.erase(found,1);
//found=input.find_first_of("\t\n ");
found=input.find_first_of(white);
}
return;
}
bool StochHMM::compXval ( const std::pair< double, double > &  a,
const std::pair< double, double > &  b 
)

Definition at line 121 of file weight.cpp.

Referenced by StochHMM::weight::getWeightedScore().

{
return (a.first<b.first);
}
template<class T >
T StochHMM::construct_histogram ( std::vector< T > &  set,
int  N_bins 
)

Definition at line 49 of file statistics.cpp.

References max(), and min().

{
T mini=min(set);
T maxi=max(set);
T delta=(maxi-mini+1)/N_bins;
std::vector<T> bin (N_bins,0);
for(int i=set.size()-1;i>=0;i--){
T value=floor((set[i]-mini)/delta);
bin(value)=bin(value)+1/(set.size()*delta);
}
return bin;
}
float StochHMM::continuous_uniform_cdf ( float  ,
float  ,
float   
)
void StochHMM::cUniform ( std::vector< double > &  dist,
int  lower,
int  upper 
)

Discrete Uniform Cumulative Distribution *a href = "http://en.wikipedia.org/wiki/Uniform_distribution_(discrete)">

Definition at line 167 of file distributions.cpp.

{
for(int k=0;k<=upper;k++){
if (k<lower){
dist.push_back(0);
}
else if (k>=lower && k<=upper){
double val=(k-lower+1)/(upper-lower+1);
dist.push_back(val);
}
}
return;
}
double StochHMM::degenerate_distribution ( double  )
float StochHMM::discrete_uniform_cdf ( int  a,
int  b,
int  position 
)

Discrete Uniform CDF *param a Minimum position *param b Maximum position *param position Position to calculate

Definition at line 163 of file statistics.cpp.

{
if (position<a){
return 0;
}
else if (position>=b){
return 1;
}
else{
return (float)(position-a+1)/(b-a+1);
}
}
template<typename T >
void StochHMM::divideValueToVector ( std::vector< T > &  vec,
value 
)

Definition at line 300 of file stochMath.h.

{
for(size_t i=0;i<vec.size();i++){
vec[i]/=value;
}
return;
}
std::string StochHMM::double_to_string ( double  input)
std::string StochHMM::double_to_string ( float  input)

Convert a double to a string

Parameters:
inputDouble you want to convert to a string

Definition at line 594 of file text.cpp.

{
std::stringstream ss;
ss << input;
std::string s=ss.str();
return s;
}
double StochHMM::entropy ( std::vector< double > &  set)

Definition at line 65 of file stochMath.cpp.

{
double entropy=0;
for(size_t i=0;i<set.size();i++){
entropy+=set[i]*(log(set[i])/log(2));
}
return entropy*-1;
}
float StochHMM::entropy ( std::vector< float > &  set)

Shannon's Entropy in log(2) space.

Definition at line 90 of file statistics.cpp.

{
float entropy=0;
for(size_t i=0;i<set.size();i++){
entropy+=set[i]*(log(set[i])/log(2));
}
return entropy*-1;
}
double StochHMM::erf ( double  x)

Definition at line 353 of file statistics.cpp.

References upper_igamma().

Referenced by sLogNormal(), sMaxwellBoltzman(), sNormal(), std_normal_cdf(), and truncated_normal_pdf().

{
return 1-(upper_igamma(0.5,pow(x,2))/sqrt(2));
}
double StochHMM::expon_cdf ( double  x,
double  beta 
)

Definition at line 295 of file statistics.cpp.

References gamma_cdf().

{
return gamma_cdf(x,1.0,beta);
}
double StochHMM::expon_pdf ( double  x,
double  beta 
)

Definition at line 291 of file statistics.cpp.

References gamma_pdf().

{
return gamma_pdf(x,1.0,beta);
}
double StochHMM::exponential_cdf ( double  )
template<typename T >
void StochHMM::expVector ( std::vector< T > &  data)

Definition at line 397 of file stochMath.h.

Referenced by StochHMM::transition::_parseLexical(), avgLogVector(), and StochHMM::emm::parse().

{
for(size_t i=0;i<data.size();i++){
data[i]=exp(data[i]);
}
return;
}
double StochHMM::extended_negative_binomial_cdf ( double  )
stringList StochHMM::extractTag ( std::string &  txt)

Parse a line and extract a bracketed tag from the model file Returns a stringList which contains the tag split using ":\\t[space]"

Parameters:
txtString to be have tag extracted from

Definition at line 743 of file text.cpp.

References balanced_brackets(), and StochHMM::stringList::splitString().

Referenced by StochHMM::emm::_processTags(), StochHMM::transition::_processTags(), and StochHMM::track::parse().

{
stringList lst;
std::pair<size_t,size_t> tagCoord = balanced_brackets(txt,"[]");
if (tagCoord.first!=tagCoord.second){
std::string tag = txt.substr(tagCoord.first+1,tagCoord.second-tagCoord.first-1);
txt.erase(tagCoord.first,tagCoord.second-tagCoord.first+1);
lst.splitString(tag,":\t ");
}
return lst;
}
double StochHMM::extrapolate ( std::pair< double, double > &  a,
std::pair< double, double > &  b,
double &  cx 
)

Extrapolates the Y value of point given by cx and two previous points.

Parameters:
apair of doubles (X1,Y1)
bpair of doubles (X2,Y2)
cxdouble value of X

Definition at line 51 of file stochMath.cpp.

Referenced by StochHMM::weight::getWeightedScore().

{
return a.second+((cx-a.first)/(b.first-a.first))*(b.second-a.second);
}
double StochHMM::F_cdf ( double  )
double StochHMM::factorial ( double  x)

Definition at line 236 of file stochMath.cpp.

Referenced by multivariate_ewens_pdf(), poisson_pdf(), and sPoisson().

{
double f=sqrt((2*x+(1/3))*M_PI)*pow(x,x)*exp(-1*x);
return floor(f);
}
double StochHMM::fisher_z_cdf ( double  )
double StochHMM::folded_normal_distribution ( double  )
double StochHMM::gamma_cdf ( double  )
double StochHMM::gamma_cdf ( double  x,
double  alpha,
double  beta 
)

Definition at line 261 of file statistics.cpp.

References beta(), gamma_pdf(), and integrate().

Referenced by chi2_cdf(), and expon_cdf().

{
std::vector<double> parameters (2,0.0);
parameters[0]=alpha;
parameters[1]=beta;
return integrate(gamma_pdf,0.0,x,parameters);
}
double StochHMM::gamma_func ( double  x)

Definition at line 240 of file statistics.cpp.

References PI.

Referenced by multinomial_pdf(), and upper_igamma().

{
if (x>0 && x<=0.5){
return sin(PI*x)*gamma_func(1-x); }
else {
return sqrt((2*PI)/x)*pow(((x/exp(1))*sqrt(x*sinh(1/x)+1/810*pow(x,6))),x);
}
}
double StochHMM::gamma_pdf ( double  x,
std::vector< double >  param 
)

Definition at line 257 of file statistics.cpp.

References gamma_pdf().

{ //double x, double alpha, double beta) {
return gamma_pdf(x,param[0],param[1]);
}
void StochHMM::generateUnknownIndices ( std::vector< size_t > &  results,
size_t  alphabetSize,
size_t  order,
size_t  value 
)

Definition at line 33 of file stochMath.cpp.

References POWER.

{
results.assign(alphabetSize,0);
for (size_t i = 0; i < (size_t) alphabetSize; i++){
results[i]= (size_t)value + i * (size_t) POWER[order-1][alphabetSize-1];
}
return;
}
double StochHMM::geometric_cdf ( double  )
void StochHMM::getKeyValue ( std::string &  txt,
std::string &  key,
std::string &  value 
)

Parses key and value from a line Where key is delimited by <<KEY>> = Value

Parameters:
txtString to extract key value from
keyString to assign key to
valueString to assign value to

Definition at line 467 of file text.cpp.

References removeLeadingWS(), and StochHMM::stringList::splitString().

Referenced by StochHMM::model::_processTemplateState().

{
size_t found=txt.find("<<");
if (found==std::string::npos){
removeLeadingWS(txt,"\t \n");
value=txt;
return;
}
else{
size_t ending=txt.find(">>");
if (ending!=std::string::npos){
key=txt.substr(found+2,ending-(found+2));
stringList lst;
lst.splitString(txt,"=");
removeLeadingWS(lst[1],"\t \n");
value= lst[1];
return;
}
else{
std::cerr << "Missing closing brackets on Key\n";
exit(1);
}
}
}
double StochHMM::half_normal_distribution ( double  )
double StochHMM::hotelling_t_square_cdf ( double  )
double StochHMM::hypergeometric_cdf ( double  )
double StochHMM::hypergeometric_cdf ( int  n,
int  N,
int  m,
int  k 
)

Hypergeometric Cumulative Distribution Function *param n Number of draws from Population *param N Size of population *param m Number of successes in Population *param k Number of successes

Definition at line 224 of file statistics.cpp.

References bin_coef().

{
if (n==N){
return 1.0;
}
else{
double prob=0;
for(int i=1; i<=n;i++){
prob+=(bin_coef(m, k)*bin_coef(N-m,i-k))/bin_coef(N, i);
}
return prob;
}
}
double StochHMM::ibeta ( double  x,
double  a,
double  b 
)

Definition at line 198 of file stochMath.cpp.

References betaPDF().

Referenced by ribeta().

{
return betaPDF(x,a,b) * exp(log(tgamma(a)) + log(tgamma(b)) - log(tgamma(a+b)));
}
double StochHMM::igamma_lower ( double  a,
double  x 
)

http://wwwC/.rskey.org/CMS/index.php/the-library/11

Definition at line 166 of file stochMath.cpp.

Referenced by cChiSquared(), cGamma(), igamma_upper(), rgammap(), sChiSquared(), and sGamma().

{
double constant = pow(x,a) * exp(-1 * x);
double sum =0;
for (int n=0;n<60;n++){
double num = pow(x,(double)n);
double denom=a;
for(int m=1;m<=n;m++){
denom*=a+m;
}
num/=denom;
sum+=num;
}
return constant * sum;
}
double StochHMM::igamma_upper ( double  s,
double  x 
)

Definition at line 159 of file stochMath.cpp.

References igamma_lower().

Referenced by rgammaq(), and sPoisson().

{
return tgamma(s)-igamma_lower(s,x);
}
std::string StochHMM::int_to_string ( int  input)

Convert an integer to a string

Parameters:
inputInteger you want to convert to string;

Definition at line 564 of file text.cpp.

Referenced by join(), StochHMM::emm::parse(), StochHMM::emm::stringify(), StochHMM::ExDef::stringify(), StochHMM::sequence::stringify(), StochHMM::weightDef::stringify(), StochHMM::sequences::stringify(), StochHMM::transition::stringify(), and StochHMM::sequences::undigitize().

{
std::stringstream ss;
ss << input;
std::string s=ss.str();
return s;
}
std::string StochHMM::int_to_string ( size_t  input)

Convert an size_t to a string

Parameters:
inputInteger you want to convert to string;

Definition at line 574 of file text.cpp.

{
std::stringstream ss;
ss << input;
std::string s=ss.str();
return s;
}
template<typename T >
T StochHMM::integerPower ( base,
exponent 
)

Integer Power function The function is overflow safe, all the calculations are checked to make sure that the result won't overflow. Works for positive or negative bases. Any overflow will result in the return value of zero

Parameters:
base
exponent
Returns:
zero if underflow or overflow occurs.

Definition at line 135 of file stochMath.h.

References max().

Referenced by StochHMM::lexicalTable::init_array_dimension_values().

{
bool negative(false);
if (base<1){
base=abs(base);
if (exponent%2!=0){
negative=true;
}
}
T result = 1;
while (exponent)
{
if (exponent & 1){
if (result > max/base){ //Determine if value of result*base > INT_MAX;
return 0;
}
result *= base;
}
exponent >>= 1;
if (exponent != 0){
if (base > max/base){ //Determine if value of base*base > INT_MAX;
return 0;
}
base *= base;
}
}
if (negative){
return (-1*result);
}
return (result);
};
double StochHMM::integrate ( double(*)(double, std::vector< double > &)  funct,
double  lower,
double  upper,
std::vector< double > &  param,
double  max_error = 0.000001,
double  sum = 0 
)

Definition at line 113 of file stochMath.cpp.

References _integrate(), and integrate().

{
double mid=(upper+lower)/2.0;
double left=_integrate(funct,lower, mid, param);
double right=_integrate(funct,mid,upper, param);
if (fabs(left+right-sum)<=15*max_error){
return left+right +(left+right-sum)/15;
}
return integrate(funct,lower,mid,param,max_error/2,left) + integrate(funct,mid,upper,param,max_error/2,right);
}
double StochHMM::integrate ( double(*)(double, std::vector< double >)  funct,
double  lower,
double  upper,
std::vector< double >  param,
double  max_error = 0.001,
double  sum = 0 
)

Definition at line 122 of file statistics.cpp.

References _integrate().

Referenced by beta_cdf(), gamma_cdf(), integrate(), and low_igamma().

{
double mid=(upper+lower)/2.0;
double left=_integrate(funct,lower, mid, param);
double right=_integrate(funct,mid,upper, param);
if (fabs(left+right-sum)<=15*max_error){
return left+right +(left+right-sum)/15;
}
return integrate(funct,lower,mid,param,max_error/2,left) + integrate(funct,mid,upper,param,max_error/2,right);
}
double StochHMM::interpolate ( std::pair< double, double > &  a,
std::pair< double, double > &  b,
double &  cx 
)

Interpolates the y value given cx and two surrounding points on either side a and b.

Parameters:
apair of doubles (X1,Y1)
bpair of doubles (X2,Y2)
cxdouble value X

Definition at line 43 of file stochMath.cpp.

Referenced by StochHMM::weight::getWeightedScore().

{
//std::cout << a.first << "\t" << a.second <<std::endl;
//std::cout << b.first << "\t" << b.second <<std::endl;
return a.second+(b.second-a.second)*((cx-a.first)/(b.first-a.first));
}
std::string StochHMM::intToBinString ( uint32_t  val)

Definition at line 13 of file bitwise_ops.cpp.

References SIZE_MAX.

Referenced by StochHMM::dynamic_bitset::stringify_all().

{
std::string output("");
for(size_t i = 31; i != SIZE_MAX ;--i){
if (val & (1 << i)){
output+="1";
}
else{
output+="0";
}
}
return output;
}
double StochHMM::inverse_gaussian_cdf ( double  )
bool StochHMM::isNumeric ( const std::string &  str)

Is the value of string numeric

Parameters:
strString to determine if it is numeric

Definition at line 808 of file text.cpp.

Referenced by StochHMM::transitionFuncParam::parse(), and StochHMM::emissionFuncParam::parse().

{
size_t found;
found = str.find_first_not_of("0123456789.-eE");
if (found!=std::string::npos){
return false;
}
else{
return true;
}
}
std::string StochHMM::join ( std::vector< int > &  input,
char  c 
)

Converts a vector of ints into a string delimited by a character c

Parameters:
inputVector of integers to be converted
cCharacter to use as a delimiter

Definition at line 519 of file text.cpp.

References int_to_string().

Referenced by StochHMM::multiTraceback::print_hits(), StochHMM::PWM::stringify(), StochHMM::emm::stringify(), StochHMM::stringList::stringify(), StochHMM::matrixPosition::stringify(), and StochHMM::track::stringify().

{
std::string out;
if (input.size()==0){
out="";
return out;
}
else if (input.size()==1){
out=int_to_string(input[0]);
return out;
}
else{
out=int_to_string(input[0]);
for(size_t i=1;i<input.size();i++){
out+=c;
out+=int_to_string(input[i]);
}
return out;
}
}
std::string StochHMM::join ( std::vector< size_t > &  input,
char  c 
)

Converts a vector of size_t into a string delimited by a character c

Parameters:
inputVector of integers to be converted
cCharacter to use as a delimiter

Definition at line 542 of file text.cpp.

References int_to_string().

{
std::string out;
if (input.size()==0){
out="";
return out;
}
else if (input.size()==1){
out=int_to_string(input[0]);
return out;
}
else{
out=int_to_string(input[0]);
for(size_t i=1;i<input.size();i++){
out+=c;
out+=int_to_string(input[i]);
}
return out;
}
}
std::string StochHMM::join ( std::vector< short > &  input,
char  c 
)

Converts a vector of shorts into a string delimited by a character c

Parameters:
inputVector of shorts to be converted
cCharacter to use as a delimiter

Definition at line 650 of file text.cpp.

References int_to_string().

{
std::string out;
if (input.size()==0){
out="";
return out;
}
else if (input.size()==1){
out=int_to_string(input[0]);
return out;
}
else{
out=int_to_string(input[0]);
for(size_t i=1;i<input.size();i++){
out+=c;
out+=int_to_string(input[i]);
}
return out;
}
}
std::string StochHMM::join ( std::vector< double > &  input,
char  c 
)

Converts a vector of doubles into a string delimited by a character c

Parameters:
inputVector of doubles to be converted
cCharacter to use as a delimiter

Definition at line 673 of file text.cpp.

References double_to_string().

{
std::string out;
if (input.size()==0){
out="";
return out;
}
else if (input.size()==1){
out=double_to_string(input[0]);
return out;
}
else{
out=double_to_string(input[0]);
for(size_t i=1;i<input.size();i++){
out+=c;
out+=double_to_string(input[i]);
}
return out;
}
}
std::string StochHMM::join ( std::vector< std::string > &  input,
char  c 
)

Converts a vector of strings into a string delimited by a character c

Parameters:
inputVector of strings to be converted
cCharacter to use as a delimiter

Definition at line 696 of file text.cpp.

{
std::string out;
size_t sz=input.size();
if (sz==1){
out = input[0];
}
else if(sz>1){
out+=input[0];
for(size_t i=1;i<sz;i++){
out+= c + input[i];
}
}
return out;
}
double StochHMM::log_logistic_cdf ( double  )
double StochHMM::log_normal_cdf ( double  )
double StochHMM::logarithmic_cdf ( double  )
double StochHMM::logit ( double  x)
inline

Logit function Inverse of the sigmoidal logistic function *Also known as log-odds score or ratio

Definition at line 581 of file stochMath.h.

Referenced by logit_normal_pdf().

{
return log(x/(1-x));
}
template<typename T >
void StochHMM::logProbVector ( std::vector< T > &  data)

Definition at line 444 of file stochMath.h.

References sumVector().

{
T sum=sumVector(data);
for(size_t iter=0;iter<data.size();iter++){
if (sum==0){
data[iter]=-INFINITY;
}
else{
data[iter] = log(data[iter]/sum);
}
}
return;
}
template<typename T >
void StochHMM::logVector ( std::vector< T > &  data)

Definition at line 385 of file stochMath.h.

Referenced by StochHMM::transition::_parseLexical(), and StochHMM::emm::parse().

{
for(size_t i=0;i<data.size();i++){
data[i]=log(data[i]);
}
return;
}
double StochHMM::low_igamma ( double  x,
double  alpha 
)

Definition at line 343 of file statistics.cpp.

References _low_igamma(), and integrate().

Referenced by upper_igamma().

{
std::vector<double> parameters (2,0.0);
parameters[0]=alpha;
return (integrate(_low_igamma,0.0,x,parameters));
}
size_t StochHMM::lowestBitSet ( uint32_t  x)

Definition at line 56 of file bitwise_ops.cpp.

{
static const unsigned int MultiplyDeBruijnBitPosition[32] =
{
// precomputed lookup table
0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8,
31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9
};
// leave only lowest bit
x &= -int(x);
// DeBruijn constant
x *= 0x077CB531;
// get upper 5 bits
x >>= 27;
// convert to actual position
return MultiplyDeBruijnBitPosition[x];
}
template<typename T >
T StochHMM::lso ( T &  val,
uint8_t  n 
)

Left Shift with shift off *Shifts the value to the left by n bits. The bits that would get shifted off value are returned in lsb

Definition at line 55 of file bitwise_ops.h.

References CHAR_BIT.

Referenced by StochHMM::dynamic_bitset::insert(), and StochHMM::dynamic_bitset::operator<<=().

{
T temp(val);
if (n>=(sizeof(T)*CHAR_BIT)){
val = 0;
}
else{
val <<=n;
}
n%=32;
return temp >> ((sizeof(T)*CHAR_BIT) - n);
};
template<typename T >
T StochHMM::lsoso ( T &  val,
T &  old_val,
uint8_t  n 
)

Left Shift with shift off *Shifts the value to the left by n bits. The bits that get shifted off val are returned in lsb of return value

Parameters:
[in,out]valValue to shift
[in]old_valValues to shift on to val
Returns:
value with bits that are shifted off val in lsb

Definition at line 91 of file bitwise_ops.h.

References CHAR_BIT.

Referenced by StochHMM::dynamic_bitset::operator<<=().

{
T temp(val);
val = (val << n) | old_val;
return temp >> ((sizeof(T)*CHAR_BIT) - n);
};
uint32_t StochHMM::maskLeft ( uint32_t  val,
uint8_t  pos 
)

Returns integer's higher bits from position up to msb *Lower bits are set to zero

Definition at line 86 of file bitwise_ops.cpp.

Referenced by StochHMM::dynamic_bitset::erase(), and StochHMM::dynamic_bitset::insert().

{
if (pos>=32){
return 0;
}
return val & ~((1 << pos) - 1);
}
uint32_t StochHMM::maskRight ( uint32_t  val,
uint8_t  pos 
)

Returns integer's lower bits from position down to lsb *Higher bits are set to zero

Definition at line 96 of file bitwise_ops.cpp.

Referenced by StochHMM::dynamic_bitset::erase(), and StochHMM::dynamic_bitset::insert().

{
if (pos >31){
return 0;
}
else if (pos == 31){
return val & (1<<31);
}
return val & ((1 << pos+1) - 1);
}
template<class T >
T StochHMM::max ( std::vector< T > &  set)

Definition at line 40 of file statistics.cpp.

References min().

Referenced by construct_histogram(), StochHMM::track::getIndex(), integerPower(), StochHMM::weight::parse(), StochHMM::track::setIndex(), StochHMM::sequences::setLength(), StochHMM::trellis::traceback_posterior(), and StochHMM::track::track().

{
T max=set[0];
for(long i=set.size()-1;i>0;i--){
if (set[i]>max){ max=set[i];}
}
return min;
}
template<typename T >
T StochHMM::maxVector ( std::vector< T > &  data)

Definition at line 366 of file stochMath.h.

{
return *max_element(data.begin(), data.end());
}
template<class T >
T StochHMM::min ( std::vector< T > &  set)

Definition at line 31 of file statistics.cpp.

Referenced by construct_histogram(), StochHMM::seqTracks::getNext(), max(), and StochHMM::weight::parse().

{
T min =set[0];
for(long i=set.size()-1;i>0;i--){
if (set[i]<min){ min=set[i];}
}
return min;
}
template<typename T >
T StochHMM::minVector ( std::vector< T > &  data)

Definition at line 357 of file stochMath.h.

{
return *min_element(data.begin(), data.end());
}
size_t StochHMM::msb ( uint32_t  val)

Definition at line 27 of file bitwise_ops.cpp.

{
const uint32_t mask[] = {
0x00000FFFF,
0x0000000FF,
0x00000000F,
0x000000003,
0x000000001
};
int hi = 32;
int lo = 0;
int i = 0;
if (val == 0)
return 0;
for (i = 0; i < 5; i++) {
int mi = lo + (hi - lo) / 2;
if ((val >> mi) != 0)
lo = mi;
else if ((val & (mask[i] << lo)) != 0)
hi = mi;
}
return lo;
}
double StochHMM::multinomial_pdf ( std::vector< int >  r,
int  n,
std::vector< double >  p 
)

check to make sure this is right;

Definition at line 322 of file statistics.cpp.

References gamma_func().

{
double prob=1.0;
double denom=1.0;
if (r.size()==p.size()){return 0.0;}
else {
for(int i=0;i<r.size();i++){
prob*=p[i];
denom*=gamma_func(r[i]);
}
}
return gamma_func((n+1)/denom)*prob; ///check to make sure this is right;
}
template<typename T >
void StochHMM::multiplyValueToVector ( std::vector< T > &  vec,
value 
)

Definition at line 286 of file stochMath.h.

Referenced by StochHMM::Index::operator*(), and StochHMM::Index::operator*=().

{
for(size_t i=0;i<vec.size();i++){
vec[i]*=value;
}
return;
}
template<typename T >
void StochHMM::multiplyVectorCombinatorial ( std::vector< T > &  result,
std::vector< T > &  lhs,
std::vector< T > &  rhs 
)

Definition at line 241 of file stochMath.h.

{
if (result.size()>0){
result.clear();
}
//If either vector is empty then return copy of the other
if (lhs.size()==0){
result.assign(rhs.begin(),rhs.end());
return;
}
else if (rhs.size()==0){
result.assign(lhs.begin(),lhs.end());
return;
}
for(size_t i=0;i<lhs.size();i++){
for(size_t j=0;j<rhs.size();j++){
result.push_back(lhs[i]*rhs[j]);
}
}
return;
}
double StochHMM::negative_binomial_cdf ( double  )
double StochHMM::noncentral_chi_cdf ( double  )
std::ostream& StochHMM::operator<< ( std::ostream &  output,
const dynamic_bitset &  bs 
)

Overloaded ostream for using dynamic_bitsets in ostream *Usage: std::cout << bs << ....;

Definition at line 270 of file dynamic_bitset.cpp.

References StochHMM::dynamic_bitset::stringify().

{
output << bs.stringify();
return output;
}
double StochHMM::parabolic_fractal_cdf ( double  )
double StochHMM::pareto_cdf ( double  )
std::string StochHMM::parseComment ( std::string &  txt,
char  commentChar 
)

Find first comment character and then return everything following the character.

Definition at line 422 of file text.cpp.

Referenced by StochHMM::stringList::processString(), and StochHMM::stringList::removeComments().

{
std::string comment;
size_t commentPos=txt.find_first_of(commentChar);
if (commentPos!=std::string::npos){
comment=txt.substr(commentPos);
txt=txt.substr(0,commentPos);
}
return comment;
}
double StochHMM::poisson_binomial_cdf ( double  )
double StochHMM::poisson_binomial_pdf ( size_t  k,
std::vector< double > &  p 
)

Poisson Binomial Probability mass function Iterative calculations don't make this appropriate for using with emissions

Parameters:
kValue or Number of successful trials
pProbability of Success for each trial of N trials

Definition at line 85 of file PDF.cpp.

{
if (k > p.size()){
std::cerr << "Poisson Binomial PDF Function: k > n \n";
exit(2);
}
//Calculate K=0
double prob(1.0);
for(size_t i=0; i < p.size(); ++i){
prob*=(1-p[i]);
}
if(k > 0){
//Calculate T(i)
std::vector<double> t(0,p.size());
for(size_t i=0; i < p.size(); ++i){
for (size_t j = 0; j < p.size(); ++j){
t[i] += pow(p[j]/(1-p[j]), i);
}
}
double temp(0);
for(size_t i=0; i < k; ++i){
temp+= pow(-1,i-1) * prob * t[i];
prob = temp;
}
prob *= 1/k;
}
return prob;
}
double StochHMM::poisson_cdf ( double  )
int8_t StochHMM::popCount ( uint32_t  val)

Population distance (Hamming Distance) *Returns the number of bits set in the 32bit integer

Definition at line 76 of file bitwise_ops.cpp.

{
val = val - ((val >> 1) & 0x55555555); // reuse input as temporary
val = (val & 0x33333333) + ((val >> 2) & 0x33333333); // temp
return ((val + (val >> 4) & 0xF0F0F0F) * 0x1010101) >> 24; // count
}
void StochHMM::print_vec ( std::vector< std::vector< double > > &  x)

Print 2D vector to std::cout.

Definition at line 1295 of file hmm.cpp.

{
size_t sze=x.size();
size_t internal_sze=x[0].size();
for(size_t j=0;j<sze;j++){
//cout << j << "\t";
for(size_t i=0;i<internal_sze;i++){
std::cout << x[j][i] << '\t' ;
}
std::cout << std::endl;
}
}
template<typename T >
void StochHMM::probVector ( std::vector< T > &  data)

Definition at line 420 of file stochMath.h.

References sumVector().

Referenced by StochHMM::transition::_parseLexical(), and StochHMM::emm::parse().

{
T sum=sumVector(data);
for(size_t iter=0;iter<data.size();iter++){
if (sum==0){
data[iter]=0;
}
else{
data[iter]/=sum;
}
}
return;
}
template<class T >
T StochHMM::productVector ( std::vector< T > &  data)

Multiply terms in vector and return the product.

Parameters:
dataVector of T

Definition at line 343 of file stochMath.h.

{
double product=data[0];
for(size_t i=1;i<data.size();++i){
product*=data[i];
}
return product;
}
sequence StochHMM::random_sequence ( std::vector< double > &  freq,
size_t  length,
track *  tr 
)

Randomly generate a sequence based on Probabilities of each character

Parameters:
freqReference to std::vector<double> that contains frequencies of alphabet corresponding to alphabet in track
lengthLength of sequence to generate
trPointer to StochHMM::track where alphabet and ambiguous characters are defined

Definition at line 1010 of file sequence.cpp.

References StochHMM::track::getAlpha(), StochHMM::track::getAlphaSize(), and StochHMM::sequence::setSeq().

{
sequence random_seq;
if (tr==NULL){
std::cerr << "Track is not defined" << std::endl;
return random_seq;
}
size_t alphaSize=tr->getAlphaSize();
size_t freqSize=freq.size();
if (alphaSize!=freqSize){
std::cerr << "Frequency distribution size and Alphabet size must be the same." << std::endl;
return random_seq;
}
//Create CDF of frequency distribution
std::vector<std::pair<double,std::string> > cdf;
double sum = 0.0;
for(size_t i=0;i<freqSize;++i){
sum+=freq[i];
std::pair<double,std::string> val (sum, tr->getAlpha(i));
cdf.push_back(val);
}
//Generate random sequence
std::string random_string;
for(size_t j=0;j<length;++j){
double val = ((double)rand()/((double)(RAND_MAX)+(double)(1))); //Generate random
for (size_t m=0;m<freqSize;++m){ //Check to see which value is
if (cdf[m].first>=val){
random_string+=cdf[m].second;
break;
}
}
}
random_seq.setSeq(random_string, tr);
return random_seq;
}
double StochHMM::rel_entropy ( std::vector< double > &  set,
std::vector< double > &  set2 
)

Definition at line 89 of file stochMath.cpp.

References rel_entropy().

{
double rel_entropy=0;
if (set.size()!=set2.size()){
std::cerr << "Distributions aren't the same size";
}
for(size_t i=0;i<set.size();i++){
rel_entropy+=0.5*(set[i]* (log (set[i]/set2[i]) /log(2) )+set2[i]*(log(set2[i]/set[i])/log(2)));
}
return rel_entropy;
}
float StochHMM::rel_entropy ( std::vector< float > &  set,
std::vector< float > &  set2 
)

Shannon's Relative entropy (Kullback-Leibler Divergence) *Normalized for A->B and B->A

Definition at line 98 of file statistics.cpp.

Referenced by rel_entropy().

{
float rel_entropy=0;
if (set.size()!=set2.size()){
std::cerr << "Distributions aren't the same size";
}
for(size_t i=0;i<set.size();i++){
rel_entropy+=0.5*(set[i]* (log (set[i]/set2[i]) /log(2) )+set2[i]*(log(set2[i]/set[i])/log(2)));
}
return rel_entropy;
}
void StochHMM::removeLeadingWS ( std::string &  txt,
const std::string &  ws 
)

Removes leading whitespace characters from a string

Parameters:
txtString user wants to remove whitespace from
wsString containing whitespace characters to remove

Definition at line 450 of file text.cpp.

Referenced by getKeyValue(), and StochHMM::stringList::removeLWS().

{
size_t start = txt.find_first_not_of(ws);
if (start==std::string::npos){
txt="";
}
else{
txt=txt.substr(start);
}
return;
}
void StochHMM::replaceChar ( std::string &  txt,
char  ch,
char  replaceCh 
)

Replace a given character with another character in a string

Parameters:
txtString to use have characters replaced
chCharacter to search string for
replaceChCharacter to replace found ch with

Definition at line 507 of file text.cpp.

{
size_t found = txt.find(ch);
while(found!=std::string::npos){
txt[found]=replaceCh;
found=txt.find(ch);
}
return;
}
double StochHMM::rgammap ( double  s,
double  x 
)

Definition at line 182 of file stochMath.cpp.

References igamma_lower().

{
return igamma_lower(s,x)/tgamma(s);
}
double StochHMM::rgammaq ( double  s,
double  x 
)

Definition at line 187 of file stochMath.cpp.

References igamma_upper().

{
return igamma_upper(s,x)/tgamma(s);
}
double StochHMM::ribeta ( double  x,
double  a,
double  b 
)

Definition at line 231 of file stochMath.cpp.

References beta(), and ibeta().

Referenced by cFDistribution(), sFDistribution(), and sNegativeBinomial().

{
return ibeta(x,a,b)/beta(a,b);
}
uint32_t StochHMM::rol ( uint32_t &  val,
uint8_t  shift_register 
)
template<typename T >
T StochHMM::rol ( val,
uint8_t  shift_register 
)

Rotate Left with carry over.

Definition at line 40 of file bitwise_ops.h.

References CHAR_BIT.

{
return (val << shift_register) | (val >> ((sizeof(T)*CHAR_BIT) - shift_register));
};
uint32_t StochHMM::ror ( uint32_t &  val,
uint8_t  shift_register 
)
template<typename T >
T StochHMM::ror ( val,
uint8_t  shift_register 
)

Rotate Right with carry over.

Definition at line 47 of file bitwise_ops.h.

References CHAR_BIT.

{
return (val >> shift_register) | (val << ((sizeof(T)*CHAR_BIT) - shift_register));
}
template<typename T >
T StochHMM::rso ( T &  val,
uint8_t  n 
)

Right Shift with shift off *Shifts the value to the right by n bits. The bits that would get shifted off value are returned in msb

Definition at line 71 of file bitwise_ops.h.

References CHAR_BIT.

Referenced by StochHMM::dynamic_bitset::erase(), and StochHMM::dynamic_bitset::operator>>=().

{
T temp(val);
if (n>=(sizeof(T)*CHAR_BIT)){
val = 0;
}
else{
val >>=n;
}
n%=32;
return temp << ((sizeof(T)*CHAR_BIT) - n);
}
template<typename T >
T StochHMM::rsoso ( T &  val,
T &  old_val,
uint8_t  n 
)

Right Shift with shift off *Shifts the value to the right by n bits. The bits that would get shifted off value are returned in msb of return value

Parameters:
[in,out]valValue to shift
[in]old_valValues to shift on to val

Definition at line 103 of file bitwise_ops.h.

References CHAR_BIT.

Referenced by StochHMM::dynamic_bitset::operator>>=().

{
T temp(val);
val = (val>>n) | old_val;
return temp << ((sizeof(T)*CHAR_BIT) - n);
}
void StochHMM::sBetaBinomial ( std::vector< double > &  dist,
int  trials,
double  a,
double  b 
)

BetaBinomial Survival Function *a href = "http://en.wikipedia.org/wiki/Beta-binomial_model">

Parameters:
[out]dist
trialsNumber of trials
aalpha
bbeta

Definition at line 74 of file distributions.cpp.

References beta(), bin_coef(), and maximum.

{
double cdf = 0;
for (int i=1; i<maximum;i++){
double newAlpha = (double) i + a;
double newBeta = (double)(trials-i) + b;
double pmf = bin_coef(trials,i) * (beta(newAlpha,newBeta)/ beta(a,b));
cdf+=pmf;
double val=1-cdf;
if (val<=0){
dist.push_back(1.0);
break;
}
else{
dist.push_back(val);
}
}
return;
}
void StochHMM::sBinomial ( std::vector< double > &  dist,
int  trials,
double  prob 
)

Binomial Distribution Survival Function

Parameters:
[out]dist
trialsNumber of trials in experiment
probProbability of success

Definition at line 26 of file distributions.cpp.

References bin_coef(), and maximum.

{
//http://en.wikipedia.org/wiki/Binomial_distribution
double cdf=0;
for (int i=1; i<maximum;i++){
double pmf=bin_coef(trials,i)*pow(prob,i)*pow(1-prob,trials-i);
cdf+=pmf;
double val=1-cdf;
if (val<=0){
break;
}
else{
dist.push_back(val);
}
}
return;
}
void StochHMM::sCauchy ( std::vector< double > &  dist,
double  location,
double  scale 
)

Definition at line 234 of file distributions.cpp.

References maximum.

{
//http://en.wikipedia.org/wiki/Cauchy_distribution
for (int i=0; i<maximum;i++){
double val=1-((1/M_PI)*atan((i-location)/scale)+0.5);
if (val==0){
break;
}
else{
dist.push_back(val);
}
}
return;
}
void StochHMM::sChiSquared ( std::vector< double > &  dist,
double  df 
)

Complement CDF/Survival of Chi-Squared Distribution

Parameters:
[out]distVector to store distribution in
dfDegrees of freedom

Definition at line 263 of file distributions.cpp.

References igamma_lower(), and maximum.

{
//http://en.wikipedia.org/wiki/Chi-square_distribution
for (double i=1; i<maximum;i++){
//CDF Value
double val=1.0/tgamma(df/2.0);
double div=igamma_lower(df/2.0, i/2.0);
val*=div;
//CCDF value
val = 1-val;
if (fabs(val)<0.00001){
break;
}
else{
dist.push_back(val);
}
}
return;
}
void StochHMM::sDegenerate ( std::vector< double > &  dist,
double  value 
)

Degenerate Survival Function *Support consists of only one value

Parameters:
[out]dist
value

Definition at line 127 of file distributions.cpp.

{
for (int i=0;i<value;i++){
dist.push_back(1);
}
dist.push_back(0);
return;
}
void StochHMM::sExponential ( std::vector< double > &  dist,
double  lambda 
)

Complement CDF Exponential Distribution

Parameters:
[out]dist
lambdaValue of lambda to use *a href = "http://en.wikipedia.org/wiki/Exponential_distribution">

Definition at line 292 of file distributions.cpp.

References maximum.

{
for (int i=0; i<maximum;i++){
double val=exp(-1*lambda*i);
if (val==0){
break;
}
else{
dist.push_back(val);
}
}
return;
}
void StochHMM::sExtremeValue ( std::vector< double > &  ,
double  ,
double  ,
double   
)
void StochHMM::sFDistribution ( std::vector< double > &  dist,
double  dOne,
double  dTwo 
)

Definition at line 356 of file distributions.cpp.

References maximum, and ribeta().

{
//http://en.wikipedia.org/wiki/F_distribution
for (int i=0;i<maximum;i++){
double val=1-ribeta((dOne*i)/((dOne*i)+dTwo), dOne/2, dTwo/2);
if (val==0){
break;
}
else{
dist.push_back(val);
}
}
return;
}
void StochHMM::sGamma ( std::vector< double > &  dist,
double  shape,
double  scale 
)

Definition at line 392 of file distributions.cpp.

References igamma_lower(), and maximum.

{
//http://en.wikipedia.org/wiki/Gamma_distribution
for (int i=0;i<maximum;i++){
double val=1-igamma_lower(shape, i/scale)/tgamma(shape);
if (val==0){
break;
}
else{
dist.push_back(val);
}
}
return;
}
void StochHMM::sGeometric ( std::vector< double > &  dist,
double  p 
)

Definition at line 424 of file distributions.cpp.

References maximum.

{
//http://en.wikipedia.org/wiki/Geometric_distribution
for (int i=0;i<maximum;i++){
double val=pow((1-p),i+1);
if (val==0){
break;
}
else{
dist.push_back(val);
}
}
return;
}
void StochHMM::sHypergeometric ( std::vector< double > &  dist,
int  N,
int  m,
int  n 
)

Complement CDF Hypergeometric Distribution

Parameters:
[out]dist
NPopulation Size
mNumber of successes
nNumber of draws

Definition at line 188 of file distributions.cpp.

References bin_coef(), and maximum.

{
//http://en.wikipedia.org/wiki/Hypergeometric_distribution
double cdf=0;
for( int k=0;k<maximum;k++){ //k = number of successes
double pmf=((double)bin_coef(m,k) * (double)bin_coef(N-m,n-k))/(double) bin_coef(N,n);
cdf+=pmf;
double val=1-cdf;
if (val<=0){
break;
}
else{
dist.push_back(val);
}
}
return;
}
double StochHMM::simpson ( double(*)(double, std::vector< double >)  funct,
double  alpha,
double  beta,
double  lower,
double  upper 
)
double StochHMM::simpson ( double(*)(double, double, double)  funct,
double  alpha,
double  beta,
double  lower,
double  upper 
)

Definition at line 135 of file statistics.cpp.

Referenced by adapt_simpson().

{
double mid=(lower+upper)/2.0;
double h3=fabs(upper-lower)/6.0;
return h3*(funct(lower,alpha,beta)+4*funct(mid,alpha,beta)+funct(upper,alpha,beta));
}
double StochHMM::simpson ( double(*)(double, std::vector< double > &)  funct,
double  alpha,
double  beta,
double  lower,
double  upper 
)
double StochHMM::skellam_cdf ( double  )
void StochHMM::sLaplace ( std::vector< double > &  dist,
double  location,
double  scale 
)

Definition at line 457 of file distributions.cpp.

References maximum.

{
//http://en.wikipedia.org/wiki/Laplace_distribution
for( int i=0;i<maximum;i++){
double val=(1/(2*scale))*exp(-1*(fabs(i-location)/scale));
if (val==0){
break;
}
else{
dist.push_back(val);
}
}
return;
}
void StochHMM::sLogarithmic ( std::vector< double > &  dist,
double  prob 
)

Definition at line 488 of file distributions.cpp.

References maximum.

{
//http://en.wikipedia.org/wiki/Logarithmic_distribution
double cdf=0;
for( int i=1;i<maximum;i++){
double pmf=(-1/log(1-prob))*((pow(prob,i)/i));
cdf+=pmf;
double val=1-cdf;
if (val==0){
break;
}
else{
dist.push_back(val);
}
}
return;
}
void StochHMM::sLogistic ( std::vector< double > &  dist,
double  location,
double  scale 
)

Definition at line 506 of file distributions.cpp.

References maximum.

{
//http://en.wikipedia.org/wiki/Logistic_distribution
for( int i=0;i<maximum;i++){
double val=1-(1/(1+exp(-1*(i-location)/scale)));
if (val==0){
break;
}
else{
dist.push_back(val);
}
}
return;
}
void StochHMM::sLogNormal ( std::vector< double > &  dist,
double  location,
double  scale 
)

Definition at line 472 of file distributions.cpp.

References erf(), and maximum.

{
//http://en.wikipedia.org/wiki/Lognormal_distribution
for( int i=0;i<maximum;i++){
double val=0.5+0.5*(erf((log(i-location)/sqrt(2*pow(scale,2)))));
if (val==0){
break;
}
else{
dist.push_back(val);
}
}
return;
}
std::string StochHMM::slurpFile ( std::string &  file)

Slurp a file into a string

Parameters:
fileFilename
Returns:
string that contains complete file

Definition at line 823 of file text.cpp.

Referenced by StochHMM::PWM::import(), and StochHMM::model::import().

{
std::ifstream in(file.c_str(),std::ifstream::in);
if (!in.good()){
std::cerr << "File doesn't exist:" << file;
exit(1);
}
std::stringstream sstr;
sstr << in.rdbuf();
return sstr.str();
}
void StochHMM::sMaxwellBoltzman ( std::vector< double > &  dist,
double  scale 
)

Definition at line 522 of file distributions.cpp.

References erf(), and maximum.

{
//http://en.wikipedia.org/wiki/Maxwell–Boltzmann_distribution
for( int i=0;i<maximum;i++){
double error=erf(i/(sqrt(2)*scale));
double i_squared=-1*pow((double)i,2);
double val=sqrt(2*(1/M_PI))*((double)i*exp(i_squared/(2*pow(scale,2)))/scale);
double boltz=1-(error-val);
if (boltz==0){
break;
}
else{
dist.push_back(boltz);
}
}
return;
}
template<class T >
T StochHMM::smooth_histogram ( std::vector< T >  histo,
int  intervals,
int  window_size,
int  iterations 
)

Definition at line 62 of file statistics.cpp.

{
std::vector<T> s_histo=histo;
for (int i=1;i<=iterations;i++){
for (int b=0;b<=intervals-window_size;b++){
int c=b+floor((window_size-1)/2);
s_histo[c]=0;
for (int j=b;j<=b+window_size-1;i++){
s_histo[c]=s_histo[c]+histo[j]/window_size;
}
}
for (int b=0;b<=((window_size-1)/2)-1;b++){
s_histo=s_histo[floor((window_size-1)/2)];
}
for (int b=intervals-window_size+1+floor((window_size-1)/2); b<=intervals-1;i++){
s_histo[b]=s_histo[intervals-window_size+floor((window_size-1) / 2)];
}
histo=s_histo;
}
T sum=0;
for (int b=0;b<=intervals-1;b++){
sum+=sum+s_histo[b];
}
for (int b=0;b<=intervals-1;b++){
s_histo[b]/=sum;
}
return s_histo;
}
template<class T >
T StochHMM::smooth_histogram ( std::vector< T > &  ,
int  ,
int  ,
int   
)
void StochHMM::sNegativeBinomial ( std::vector< double > &  dist,
int  r,
double  p 
)

Definition at line 540 of file distributions.cpp.

References maximum, and ribeta().

{
//http://en.wikipedia.org/wiki/Negative_binomial_distribution
for( int i=0;i<maximum;i++){
double val=ribeta(p, i+1, r);
if (val==0){
break;
}
else{
dist.push_back(val);
}
}
return;
}
void StochHMM::sNonCentralF ( std::vector< double > &  ,
double  ,
double  ,
double   
)
void StochHMM::sNonCentralT ( std::vector< double > &  ,
double  ,
double   
)
void StochHMM::sNormal ( std::vector< double > &  dist,
double  mean,
double  stdev 
)

Definition at line 590 of file distributions.cpp.

References erf(), and maximum.

{
//http://en.wikipedia.org/wiki/Normal_distribution
for( int i=0;i<maximum;i++){
double val=1-(0.5*(1+erf((i-mean)/sqrt(2*pow(stdev,2)))));
if (val==0){
break;
}
else{
dist.push_back(val);
}
}
return;
}
void StochHMM::sort_scores ( std::vector< nthScore > &  nth_scores)

Sort the viterbi scores in the nth trellis cells.

Definition at line 17 of file nth_best.cpp.

References _vec_sort().

Referenced by StochHMM::trellis::naive_nth_viterbi(), and StochHMM::trellis::simple_nth_viterbi().

{
sort(nth_scores.begin(), nth_scores.end(), _vec_sort );
return;
}
bool StochHMM::sortTBVec ( std::map< traceback_path, int >::iterator  lhs,
std::map< traceback_path, int >::iterator  rhs 
)

Definition at line 615 of file traceback_path.cpp.

Referenced by StochHMM::multiTraceback::finalize().

{
return ((*lhs).second < (*rhs).second);
}
void StochHMM::sPareto ( std::vector< double > &  dist,
double  shape,
double  scale 
)

Definition at line 606 of file distributions.cpp.

References maximum.

{
for( int i=0;i<maximum;i++){
double val=pow((scale/(double) i),shape);
if (val==0){
break;
}
else{
dist.push_back(val);
}
}
return;
}
void StochHMM::split_line ( std::vector< std::string > &  line,
std::string &  input 
)

Splits a line into a vector of string using delimiters ' ",[space]\n\t'

Parameters:
linevector of strings to split input into
inputString to be split using delimiters ' ",[space]\n\t'

Definition at line 716 of file text.cpp.

Referenced by StochHMM::ExDefSequence::_parseAbsDef(), and StochHMM::track::_splitAmbiguousList().

{
//split line accoring to delimiters;
size_t found=input.find_first_of("\", \n\t");
while(found!=std::string::npos){
if (found>0){
line.push_back(input.substr(0,found));
//cout << line.back() << endl;
input=input.substr(found+1);
//cout << input << endl;
}
else{
input.erase(found,1);
//cout << input <<endl;
}
found=input.find_first_of("\", \n\t");
//cout <<input <<endl;
}
if (input.size()>0){
line.push_back(input);
}
return;
}
stringList & StochHMM::splitString ( const std::string &  txt,
const std::string &  delimiters 
)

Splits string using delimiters and return stringList.

Definition at line 495 of file text.cpp.

References StochHMM::stringList::clear(), and StochHMM::stringList::splitString().

Referenced by StochHMM::state::_parseHeader(), and StochHMM::state::_parseTransition().

{
static stringList lst;
lst.clear();
lst.splitString(txt,delimiters);
return lst;
}
void StochHMM::sPoisson ( std::vector< double > &  dist,
double  lambda 
)

Definition at line 620 of file distributions.cpp.

References factorial(), igamma_upper(), and maximum.

{
//http://en.wikipedia.org/wiki/Poisson_distribution
for( int i=0;i<maximum;i++){
double val=igamma_upper(i+1,lambda)/factorial(i);
if (val==0){
break;
}
else{
dist.push_back(val);
}
}
return;
}
void StochHMM::sRayleigh ( std::vector< double > &  dist,
double  sigma 
)

Definition at line 636 of file distributions.cpp.

References maximum.

{
//http://en.wikipedia.org/wiki/Rayleigh_distribution
for( int i=0;i<maximum;i++){
double val=exp((-1*(pow((double) i, 2)))/(2*pow(sigma,2)));;
if (val==0){
break;
}
else{
dist.push_back(val);
}
}
return;
}
double StochHMM::std_normal_cdf ( double  x)

Definition at line 357 of file statistics.cpp.

References erf().

{
x/=sqrt(2);
double erf_value=erf(x);
return 0.5*(1.0+erf_value);
}
void StochHMM::sTriangular ( std::vector< double > &  dist,
int  a,
int  b,
int  c 
)

Definition at line 651 of file distributions.cpp.

{
//http://en.wikipedia.org/wiki/Triangular_distribution
double val=0;
for(int x=0;x<=b;x++){
if (x<a){
dist.push_back(1);
}
else if (x>=a && x<=c){
val=pow((double)(x-a),2)/((b-a)*(c-a));
dist.push_back(1-val);
}
else{
val=pow((double)(b-x),2)/((b-a)*(b-c));
dist.push_back(val);
}
}
return;
}
bool StochHMM::stringToDouble ( std::string &  txt,
double &  val 
)

Convert string to double

Parameters:
txtText representation of double
valInteger to be assigned
Returns:
true if conversion is valid
false if conversion can't be performed

Definition at line 636 of file text.cpp.

Referenced by StochHMM::transition::_parseDuration(), StochHMM::model::_parseHeader(), StochHMM::transition::_parseLexical(), StochHMM::transition::_parseStandard(), StochHMM::ExDefSequence::_parseWeightDef(), StochHMM::transitionFuncParam::parse(), StochHMM::emm::parse(), StochHMM::emissionFuncParam::parse(), StochHMM::weight::parse(), and StochHMM::stringList::toVecDouble().

{
std::istringstream input(txt);
if(!(input >> val)){
return false;
}
return true;
}
bool StochHMM::stringToInt ( std::string &  txt,
int &  val 
)

Convert string to integer

Parameters:
txtText representation of integer
valInteger to be assigned
Returns:
true if conversion is valid
false if conversion can't be performed

Definition at line 607 of file text.cpp.

Referenced by StochHMM::ExDefSequence::_parseAbsDef(), StochHMM::transition::_parseDuration(), StochHMM::transition::_parseLexical(), StochHMM::ExDefSequence::_parseWeightDef(), StochHMM::emm::parse(), and StochHMM::stringList::toVecInt().

{
std::istringstream input(txt);
if (!(input >> val)){
return false;
}
return true;
}
bool StochHMM::stringToInt ( std::string &  txt,
size_t &  val 
)

Convert string to integer

Parameters:
txtText representation of integer
valInteger to be assigned
Returns:
true if conversion is valid
false if conversion can't be performed

Definition at line 621 of file text.cpp.

{
std::istringstream input(txt);
if (!(input >> val)){
return false;
}
return true;
}
double StochHMM::summation ( double(*)(int, std::vector< double >)  funct,
int  lower,
int  upper,
std::vector< double >  param 
)

Definition at line 149 of file stochMath.cpp.

{
double sum=0;
for(int i=lower;i<=upper;i++){
sum+=funct(i,param);
}
return sum;
}
float StochHMM::summation ( float(*)(int, std::vector< float >)  funct,
int  lower,
int  upper,
std::vector< float >  param 
)

Definition at line 309 of file statistics.cpp.

Referenced by binomial_cdf().

{
float sum=0;
for(int i=lower;i<=upper;i++){
sum+=funct(i,param);
}
return sum;
}
double StochHMM::summation ( double(*)(int, std::vector< double > &)  funct,
int  ,
int  ,
std::vector< double > &   
)
template<class T >
T StochHMM::sumVector ( std::vector< T > &  data)

Sum the vector and return the sum.

Parameters:
dataVector of doubles

Definition at line 317 of file stochMath.h.

Referenced by avgLogVector(), avgVector(), dirichlet_pdf(), StochHMM::lexicalTable::init_table_dimension_values(), logProbVector(), and probVector().

{
double sum=0;
for(size_t i=0;i<data.size();i++){
sum+=data[i];
}
return sum;
}
template<class T >
T StochHMM::sumVector ( const std::vector< T > &  data)

Definition at line 330 of file stochMath.h.

{
double sum=0;
for(size_t i=0;i<data.size();i++){
sum+=data[i];
}
return sum;
}
void StochHMM::sUniform ( std::vector< double > &  dist,
int  lower,
int  upper 
)

Discrete Uniform Survival Function *a href = "http://en.wikipedia.org/wiki/Uniform_distribution_(discrete)">

Definition at line 152 of file distributions.cpp.

{
for(int k=0;k<=upper;k++){
if (k<lower){
dist.push_back(1);
}
else if (k>=lower && k<=upper){
double val=(k-lower+1)/(upper-lower+1);
dist.push_back(1-val);
}
}
return;
}
void StochHMM::sUser ( std::vector< double > &  dist,
std::vector< double > &  prob_dist 
)

Definition at line 674 of file distributions.cpp.

{
double c_df=0;
//calculate CDF
for(int i=0;i<prob_dist.size();i++){
c_df+=prob_dist[i];
dist.push_back(c_df);
}
//Convert CDF to survival function
for(int i=0; i<dist.size();i++){
dist[i]=1-dist[i];
}
return;
}
void StochHMM::sWeibull ( std::vector< double > &  dist,
double  shape,
double  scale 
)

Definition at line 689 of file distributions.cpp.

References maximum.

{
//http://en.wikipedia.org/wiki/Weibull_distribution
for (int i=0; i<maximum;i++){
double val=exp(-1*pow(i/scale,shape));
if (val==0){
break;
}
else{
dist.push_back(val);
}
}
return;
}
double StochHMM::upper_igamma ( double  x,
double  alpha 
)

Definition at line 349 of file statistics.cpp.

References gamma_func(), and low_igamma().

Referenced by erf().

{
return (1/gamma_func(alpha))-low_igamma(x,alpha);
}
double StochHMM::yule_simon_cdf ( double  )
double StochHMM::zeta ( double  )

Variable Documentation

int StochHMM::maximum = 1000000
const uint32_t StochHMM::POWER[32][128]
bool StochHMM::quiet
int StochHMM::WID = 80

Definition at line 32 of file traceback_path.cpp.