-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLikelihood.h
62 lines (46 loc) · 1.52 KB
/
Likelihood.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//
// Created by Huy Vo on 8/11/18.
//
#ifndef MCMC_FTT_CME_LIKELIHOOD_H
#define MCMC_FTT_CME_LIKELIHOOD_H
#include <cmath>
#include <armadillo>
#include <form.h>
#include "FSPSolver.h"
namespace cme{
struct SingleCellData{
Row<double> times;
field<arma::Mat<int>> snapshots;
};
class Likelihood {
protected:
struct SingleCellData& data;
struct Model& model;
FSPSolver fsp;
Col<double> full_dist{0.0};
field<arma::Row<int>> data2fsp;
public:
Likelihood(struct SingleCellData& _data, struct Model& _model):
data(_data),
model(_model),
full_dist({0.0}),
fsp(full_dist, _model, _data.times, 1.0e-6)
{
data2fsp.set_size(data.times.n_elem);
for (size_t it{0}; it < data.times.n_elem; ++it)
{
data2fsp(it) = sub2ind_fsp(model.FSPSize, data.snapshots(it));
}
full_dist.resize(prod(model.FSPSize+1));
// Return the full distribution to the initial condition
arma::Row<int> init_indices = sub2ind_fsp(model.FSPSize, model.states_init);
for (size_t i{0}; i < init_indices.n_elem; ++i)
{
full_dist((uword) init_indices(i)) = model.probs_init(i);
}
};
double evaluate(const Row<double>& parameters);
};
struct SingleCellData generate_data(struct Model& model, Row<double> times, Col<int> x0, size_t num_samples);
}
#endif //MCMC_FTT_CME_LIKELIHOOD_H