Augustus 3.4.0
Loading...
Searching...
No Matches
commontrain.hh
1/*
2 * commontrain.hh
3 *
4 * License: Artistic License, see file LICENSE.TXT or
5 * https://opensource.org/licenses/artistic-license-1.0
6 */
7
8#ifndef _COMMONTRAIN_HH
9#define _COMMONTRAIN_HH
10
11// project includes
12#include "types.hh"
13
14// standard C/C++ includes
15#include <vector>
16
17
18// everything below this is considered 0, for performance
19#define SMOOTH_EPSILON Double(1e-20)
20
28class Smooth {
29public:
30 Smooth (Integer minwindowcount = 0, double slope_of_bandwidth = 0.1) {
31 this->minwindowcount = minwindowcount;
32 this->slope_of_bandwidth = slope_of_bandwidth;
33 }
34 ~Smooth() {}
35
36 /*
37 * smooth the vector counts of frequencies up to position n
38 */
39 void smoothCounts(const vector<Integer> &counts, vector<Double>& result, int resultSize=-1);
40
41 /*
42 * compute an optimal cutoff value d for the start of the geometric
43 * distribution of introns
44 */
45 int geoCutOff(const vector<Integer> &lengths, vector<Double>& result);
46
47private:
48 // h: bandwidth, i difference
49 // simple triangle kernel
50 Double phi_triangle(Integer h, Integer i){
51 if (i<0) {
52 i=-i;
53 }
54 if (i <= h) {
55 return Double((1 - (double) i/h)/h);
56 } else
57 return Double(0.0);
58 }
59 // h: bandwitdth, standard error=sigma
60 // normal distribution kernel
61 Double phi_normal(double stderror, Integer i){
62 static const Double factor(0.39894228) ; // = 1/sqrt(2 pi)
63 return factor / stderror * exp(- i / stderror * i / stderror / 2);
64 }
65
66 Integer minwindowcount; // number of events that need to be at least in each smoothing window
67 double slope_of_bandwidth; // bandwidth of kernel is proportional to index
68};
69
70void scaleDblVector(vector<Double>& v, Double sum);
71
72#endif // _COMMONTRAIN_HH
This class implements a double object with a very large range.
Definition lldouble.hh:31
A class for smoothing distributions.
Definition commontrain.hh:28