1 #ifndef LOCARNA_FIT_ON_OFF_HH
2 #define LOCARNA_FIT_ON_OFF_HH
15 typedef std::vector<double> numseq_t;
16 typedef std::vector<double>::size_type
size_type;
18 typedef long double pf_t;
31 std::vector<std::vector<pf_t> > v;
33 std::vector<std::vector<bool> > t;
35 std::vector<bool> trace;
44 double delta(
int i)
const {
return delta_val;}
46 double exp_delta(
int i)
const {
return exp_delta_val;}
55 FitOnOff(numseq_t &x_,
double delta_,
double beta_)
56 : x(x_), delta_val(delta_), beta(beta_) {
58 v[0].resize(x.size() + 1);
59 v[1].resize(x.size() + 1);
62 t[0].resize(x.size() + 1);
63 t[1].resize(x.size() + 1);
64 trace.resize(x.size() + 1);
66 exp_delta_val = exp(-beta * delta_val);
77 viterbi(
double c0,
double c1,
bool traceback);
100 std::pair<double, double>
120 print_table(
const std::string &name,
const std::vector<bool> &v)
const;
129 print_table(
const std::string &name,
const std::vector<pf_t> &v)
const;
151 :
FitOnOff(x_, 0, beta_), penalties(penalties_) {
154 int length_penalties = penalties.size();
155 for (
int i = 0; i < length_penalties; i++) {
156 exp_penalties.push_back(exp(-beta_ * penalties.at(i)));
162 double delta(
int i)
const {
return penalties.at(i-1);}
164 double exp_delta(
int i)
const {
return exp_penalties.at(i-1);}
168 numseq_t exp_penalties;
Fitting of a two-step function with position-specific step penalities.
Definition: fitonoff.hh:142
FitOnOffVarPenalty(numseq_t &x_, numseq_t &penalties_, double beta_)
Definition: fitonoff.hh:150
Implements fitting of a two-step function to a number sequence.
Definition: fitonoff.hh:24
double viterbi(double c0, double c1, bool traceback)
Definition: fitonoff.cc:15
FitOnOff(numseq_t &x_, double delta_, double beta_)
Definition: fitonoff.hh:55
std::pair< double, double > optimize(double c0, double c1)
Definition: fitonoff.cc:118
double best_once_on(double c0, double c1)
Definition: fitonoff.cc:46
void print_table(const std::string &name, const std::vector< bool > &v) const
Definition: fitonoff.cc:278
void write_viterbi_path_compact(std::ostream &out, double c0, double c1)
writes the ranges in the viterbi path
Definition: fitonoff.cc:247
void write_viterbi_path(std::ostream &out, double c0, double c1) const
writes the viterbi path
Definition: fitonoff.cc:236
pf_t forward(double c0, double c1)
Definition: fitonoff.cc:103
void print_tables() const
Definition: fitonoff.cc:298
Definition: aligner.cc:15
size_t size_type
general size type
Definition: aux.hh:120