-
Notifications
You must be signed in to change notification settings - Fork 1
/
CTimeHist.h
53 lines (40 loc) · 1.17 KB
/
CTimeHist.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
#ifndef CTIMEHIST_H
#define CTIMEHIST_H
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <stdint.h>
#include "CTimer.h"
#include "CTemporal.h"
#define MAX_ID_LENGTH 100
using namespace std;
class CTimeHist: public CTemporal
{
public:
CTimeHist(int id);
~CTimeHist();
void init(int iMaxPeriod,int elements,int numActivities);
//adds a serie of measurements to the data
int add(uint32_t time,float state);
//estimates the probability for the given times - using stored histogram
float estimate(uint32_t time);
//predicts the probability for the given times - using updated histogram
float predict(uint32_t time);
void update(int maxOrder,unsigned int* times = NULL,float* signal = NULL,int length = 0);
void print(bool verbose=true);
int save(const char* name,bool lossy = false);
int load(const char* name);
int save(FILE* file,bool lossy = false);
int load(FILE* file);
int exportToArray(double* array,int maxLen);
int importFromArray(double* array,int len);
private:
int id;
float *storedHistogram;
float *predictHistogram;
int *measurementsHistogram;
int numModels;
};
#endif