eXpress “1.5”
|
lengthdistribution.h express More...
#include <lengthdistribution.h>
Public Member Functions | |
LengthDistribution (double alpha, size_t max_val, size_t prior_mu, size_t prior_sigma, size_t kernel_n, double kernel_p, size_t bin_size=1) | |
LengthDistribution Constructor. | |
LengthDistribution (std::string param_file_name, std::string length_type) | |
A second constructor that loads the distribution from a parameter file. | |
size_t | max_val () const |
An accessor for the maximum allowed length. | |
size_t | min_val () const |
An accessor for the minimum observed length (1 initially). | |
double | mean () const |
An accessor for the mean length in the distribution. | |
void | add_val (size_t len, double mass) |
A member function that updates the distribution based on a new length observation. | |
double | pmf (size_t len) const |
An accessor for the (logged) probability of a given length. | |
double | cmf (size_t len) const |
A member function that returns a (logged) cumulative mass for a given length. | |
std::vector< double > | cmf () const |
A member function that returns a vector containing the (logged) cumulative mass function *for the bins*. | |
double | tot_mass () const |
An accessor for the (logged) observation mass (including pseudo-counts). | |
std::string | to_string () const |
A member function that returns a string containing the current distribution. | |
void | append_output (std::ofstream &outfile, std::string length_type) const |
A member function that appends the LengthDistribution parameters to the end of the given file. |
lengthdistribution.h express
Created by Adam Roberts on 1/30/13. Copyright 2013 Adam Roberts. All rights reserved. The LengthDistribution class keeps track of the observed length distribution. It is initialized with a Gaussian prior with parameters specified by the arguments to the constructor. An argument-specified binomial kernel is then added for each observation. All mass values and probabilities are stored and returned in log space (except in to_string).
Definition at line 22 of file lengthdistribution.h.
LengthDistribution::LengthDistribution | ( | double | alpha, |
size_t | max_val, | ||
size_t | prior_mu, | ||
size_t | prior_sigma, | ||
size_t | kernel_n, | ||
double | kernel_p, | ||
size_t | bin_size = 1 |
||
) |
LengthDistribution Constructor.
alpha | double that sets the average pseudo-counts (logged). |
max_val | an integer that sets the maximum allowable length. |
prior_mu | a size_t for the mean of the prior gaussian distribution. If 0, a uniform distribution is used instead. |
prior_sigma | a size_t for the standard deviation of the prior gaussian distribution. |
kernel_n | a size_t specifying the number of trials in the kernel binomial distribution. Must be odd. |
kernel_p | a double specifying the success probability for the kernel binomial distribution. |
bin_size | a size_t specifying the size of bins to use internally to reduce the number of parameters in the distribution. |
Definition at line 20 of file lengthdistribution.cpp.
LengthDistribution::LengthDistribution | ( | std::string | param_file_name, |
std::string | length_type | ||
) |
A second constructor that loads the distribution from a parameter file.
Note that the values should not be modified (add_val should not be called) after using this constructor. The bin size is set to 1.
param_file_name | a string specifying the path to the parameter file. |
length_type | a string specifying the type of length distribution to be matched in the parameter file. |
void LengthDistribution::add_val | ( | size_t | len, |
double | mass | ||
) |
A member function that updates the distribution based on a new length observation.
len | an integer for the observed length. |
mass | a double for the mass (logged) to add. |
Definition at line 114 of file lengthdistribution.cpp.
void LengthDistribution::append_output | ( | std::ofstream & | outfile, |
std::string | length_type | ||
) | const |
A member function that appends the LengthDistribution parameters to the end of the given file.
outfile | the file to append to. |
length_type | a string specifying the type of length the distribution is of (ie. "Fragment" or "Target") to be included in the header. |
double LengthDistribution::cmf | ( | size_t | len | ) | const |
A member function that returns a (logged) cumulative mass for a given length.
len | an integer for the length to return the cmf value of. |
Definition at line 148 of file lengthdistribution.cpp.
vector< double > LengthDistribution::cmf | ( | ) | const |
A member function that returns a vector containing the (logged) cumulative mass function *for the bins*.
Definition at line 158 of file lengthdistribution.cpp.
size_t LengthDistribution::max_val | ( | ) | const |
An accessor for the maximum allowed length.
Definition at line 103 of file lengthdistribution.cpp.
double LengthDistribution::mean | ( | ) | const |
An accessor for the mean length in the distribution.
Definition at line 174 of file lengthdistribution.cpp.
size_t LengthDistribution::min_val | ( | ) | const |
An accessor for the minimum observed length (1 initially).
Definition at line 107 of file lengthdistribution.cpp.
double LengthDistribution::pmf | ( | size_t | len | ) | const |
An accessor for the (logged) probability of a given length.
len | an integer for the length to return the probability of. |
Definition at line 140 of file lengthdistribution.cpp.
string LengthDistribution::to_string | ( | ) | const |
A member function that returns a string containing the current distribution.
Definition at line 178 of file lengthdistribution.cpp.
double LengthDistribution::tot_mass | ( | ) | const |
An accessor for the (logged) observation mass (including pseudo-counts).
Definition at line 170 of file lengthdistribution.cpp.