本文整理汇总了C++中TimeSeries::copy方法的典型用法代码示例。如果您正苦于以下问题:C++ TimeSeries::copy方法的具体用法?C++ TimeSeries::copy怎么用?C++ TimeSeries::copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeSeries
的用法示例。
在下文中一共展示了TimeSeries::copy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: start
void HMMObserver::start() {
vector<vector<TimeSeries *> *> chunk_bins;
vector<double> current_means;
vector<double> current_ns;
vector<double> current_variance;
vector<TimeSeries *> chunks;
TimeSeries * inputTS = NULL;
if (use_csv) {
inputTS = CSVLoader::loadTSfromCSV(csvin_fname);
} else {
log_e("No input source defined. Stop.");
return;
}
#define NUM_STEPS 5
TimeSeries * inputRaw = inputTS->copy();
TRANS_DETECTOR.setParams(0.05,60);
double NEW_BIN_THRESH = 1.2;
log_prog(1,NUM_STEPS,"Detect Transitions","");
EventSeries<TransitionEvent> * es = TRANS_DETECTOR.detect(inputTS);
log_i("%d Transitions found\n",es->events.size());
if ( es->events.size() <= 1 ) {
log_i("Not enough transitions to do anything useful");
log_prog(NUM_STEPS,NUM_STEPS,"Early abort","No data");
error = 1;
return;
}
// STEP Ia : SEPARATE INTO CHUNKS
log_prog(2,NUM_STEPS,"Separate Time Chunks","");
chunks.push_back(inputTS->selectTime(inputTS->t[0],es->events[0].t));
for ( size_t c = 0; c < es->events.size() - 1; c++) {
chunks.push_back(inputTS->selectTime(es->events[c].t,es->events[c+1].t));
}
chunks.push_back(inputTS->selectTime(es->events[es->events.size()-1].t,inputTS->t[inputTS->t.size()-1]));
if (csvout_fname.size() > 0) {
TimeSeries * tsout = new TimeSeries();
tsout->metadata.push_back(" Data separated into chunks via the transition detector");
for (size_t c = 0; c < chunks.size(); c++) {
tsout->insertPointAtEnd(chunks[c]->t[0],chunks[c]->mean());
}
CSVLoader::writeTStoCSV(csvout_fname,tsout,outprec);
delete tsout;
}
if (statesin_fname.size() > 0 ) {
// STEP Ib : ORDER CHUNKS BY SIZE
log_prog(3,NUM_STEPS,"Order by Size","");
sort(chunks.begin(), chunks.end(), cmp_by_timeseries_length);
// STEP Ic : CATAGORIZE CHUNKS BY MEANS
// start with biggest chunk in first bin
chunk_bins.push_back(new vector<TimeSeries *>);
chunk_bins[0]->push_back(chunks[0]);
current_means.push_back(chunks[0]->mean());
for ( int c = 1; c < chunks.size(); c++ ) {
log_prog(4,NUM_STEPS,"Categorize by Means","%.2f%%",(100.0*c/chunks.size()));
double chmean = chunks[c]->mean();
// find the "closest" bin
int minmean = 0;
for ( int d = 1; d < chunk_bins.size(); d++ ) {
if ( fabs(chmean - current_means[d]) < fabs(chmean - current_means[minmean]) ) {
minmean = d;
}
}
// if closest bin is too far off, create a new bin
if ( current_means[minmean] / chmean > NEW_BIN_THRESH || chmean / current_means[minmean] > NEW_BIN_THRESH ) {
chunk_bins.push_back(new vector<TimeSeries *>);
chunk_bins.back()->push_back(chunks[c]);
current_means.push_back(chmean);
} else { // add to bin and update mean
current_means[minmean] = (current_means[minmean] * chunk_bins[minmean]->size() + chmean) / (chunk_bins[minmean]->size() + 1);
chunk_bins[minmean]->push_back(chunks[c]);
}
}
for ( int c = 0; c < chunk_bins.size(); c++ ) {
int varn = 0;
double varsum = 0;
double meansum = 0;
for (int d = 0; d < chunk_bins[c]->size(); d++ ) {
varn += chunk_bins[c]->at(d)->t.size();
}
current_ns.push_back(varn);
// recalculate means
for ( int d = 0; d < chunk_bins[c]->size(); d++ ) {
meansum += chunk_bins[c]->at(d)->sum();
}
meansum = current_means[c] = meansum/varn;
for (int d = 0; d < chunk_bins[c]->size(); d++ ) {
//.........这里部分代码省略.........