andrew@0
|
1 /*
|
andrew@0
|
2 * DynamicBayesianArray.h
|
andrew@0
|
3 * midiCannamReader
|
andrew@0
|
4 *
|
andrew@0
|
5 * Created by Andrew on 17/07/2011.
|
andrew@0
|
6 * Copyright 2011 QMUL. All rights reserved.
|
andrew@0
|
7 *
|
andrew@0
|
8 */
|
andrew@0
|
9
|
andrew@0
|
10 /*
|
andrew@0
|
11 * DynamicBayesianArray.cpp
|
andrew@0
|
12 * bayesianTest5
|
andrew@0
|
13 *
|
andrew@0
|
14 * Created by Andrew Robertson on 08/05/2010.
|
andrew@0
|
15 * Copyright 2010 __MyCompanyName__. All rights reserved.
|
andrew@0
|
16 *
|
andrew@0
|
17 */
|
andrew@0
|
18
|
andrew@0
|
19 /*
|
andrew@0
|
20 * DynamicBayesianArray.h
|
andrew@0
|
21 * bayesianTest5
|
andrew@0
|
22 *
|
andrew@0
|
23 * Created by Andrew Robertson on 08/05/2010.
|
andrew@0
|
24 * Copyright 2010 __MyCompanyName__. All rights reserved.
|
andrew@0
|
25 *
|
andrew@0
|
26 */
|
andrew@0
|
27
|
andrew@0
|
28 #include "ofMain.h"
|
andrew@0
|
29
|
andrew@0
|
30 #include "DynamicVector.h"
|
andrew@0
|
31
|
andrew@0
|
32 #ifndef _DYNAMIC_BAYESIAN_ARRAY
|
andrew@0
|
33 #define _DYNAMIC_BAYESIAN_ARRAY
|
andrew@0
|
34
|
andrew@0
|
35 #define ARRAY_SIZE 240
|
andrew@0
|
36
|
andrew@0
|
37
|
andrew@0
|
38 class DynamicBayesianArray{
|
andrew@0
|
39
|
andrew@0
|
40 public:
|
andrew@0
|
41
|
andrew@0
|
42 DynamicBayesianArray();
|
andrew@0
|
43 void initialiseArray();
|
andrew@0
|
44
|
andrew@0
|
45 // void setGaussianLikelihoodForBeats(float mean, float StdDev);
|
andrew@0
|
46 void setGaussianLikelihood(float mean, float StdDev);
|
andrew@0
|
47 void setGaussianPrior(float mean, float StdDev);
|
andrew@0
|
48 void setGaussianPosterior(float mean, float StdDev);
|
andrew@0
|
49
|
andrew@0
|
50 void calculatePosterior();
|
andrew@0
|
51 void renormalisePosterior();
|
andrew@0
|
52 void resetMaximumPosterior();//resets the max index
|
andrew@0
|
53 void decayPosteriorWithGaussianNoise();
|
andrew@0
|
54 void translateDistribution(int translationIndex);
|
andrew@0
|
55 void setDecayNoiseGaussian(float mean, float StdDev);
|
andrew@0
|
56 double calculateStandardDeviation();
|
andrew@0
|
57
|
andrew@0
|
58 int arraySize;
|
andrew@0
|
59
|
andrew@0
|
60
|
andrew@0
|
61 float getMaximum(float *ptr, int length);
|
andrew@0
|
62 void renormaliseArray(float *ptr, int length);
|
andrew@0
|
63 void resetPrior();
|
andrew@0
|
64 void decayPosterior();
|
andrew@0
|
65 float* getMaximumEstimate(float *ptr, int length);
|
andrew@18
|
66 double getMaximumIndex();//return the index where the probability is maximal
|
andrew@0
|
67 double getIntegratedEstimateIndex();
|
andrew@0
|
68
|
andrew@0
|
69 // void drawArray(const int& minIndex, const int& maxIndex);
|
andrew@0
|
70 void drawFloatArray(float* arrayToDraw, const int& minIndex, const int& maxIndex);
|
andrew@0
|
71 void drawDoubleArray(double* arrayToDraw, const int& minIndex, const int& maxIndex);
|
andrew@0
|
72
|
andrew@0
|
73
|
andrew@0
|
74 typedef std::vector<double> DoubleVector;
|
andrew@0
|
75 // typedef std::vector<IntVector> DoubleMatrix;
|
andrew@0
|
76
|
andrew@0
|
77
|
andrew@0
|
78 // DynamicVector prior;
|
andrew@0
|
79 // DynamicVector posterior;
|
andrew@0
|
80 // DynamicVector likelihood;
|
andrew@0
|
81
|
andrew@0
|
82 DynamicVector testVector;
|
andrew@0
|
83 // DynamicVector prior;
|
andrew@0
|
84
|
andrew@0
|
85 float prior [ARRAY_SIZE];
|
andrew@0
|
86 float posterior [ARRAY_SIZE];
|
andrew@0
|
87 float likelihood [ARRAY_SIZE];
|
andrew@0
|
88 float tempPosteriorArray[ARRAY_SIZE];
|
andrew@0
|
89
|
andrew@0
|
90 float decayNoiseArray[ARRAY_SIZE];
|
andrew@0
|
91 float decayNoiseStdDev, decayNoiseAmount;
|
andrew@0
|
92
|
andrew@0
|
93 float likelihoodMean, likelihoodStdDev, likelihoodNoise;
|
andrew@0
|
94 float maximumTest, posteriorDecayRate, maximumValue;
|
andrew@0
|
95 float eighthNoteProportion, earlySixteenthNoteProportion, lateSixteenthNoteProportion ;
|
andrew@0
|
96 float maximumEstimate, maximumIndex, integratedEstimate;
|
andrew@0
|
97 double standardDeviation;
|
andrew@0
|
98
|
andrew@0
|
99 private:
|
andrew@0
|
100 };
|
andrew@0
|
101
|
andrew@0
|
102 #endif
|
andrew@0
|
103
|
andrew@0
|
104
|
andrew@0
|
105
|