本文整理汇总了C++中TimeSeries::size方法的典型用法代码示例。如果您正苦于以下问题:C++ TimeSeries::size方法的具体用法?C++ TimeSeries::size怎么用?C++ TimeSeries::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeSeries
的用法示例。
在下文中一共展示了TimeSeries::size方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: analyze
FL::ParseResult AB::analyze(
const TimeSeries &ts, Forest &forest, Patterns::Matcher &matcher, PatternsSet &patterns, MetricsSet &metrics)
{
ParseResult result;
try
{
if (ts.size() < 2)
throw EAnalyze(E_INVALID_INPUT);
Tree *tree = new Tree(ts);
const int up = IDGenerator::idOf("a");
const int down = IDGenerator::idOf("b");
for (int i = 0; i < ts.size()-1; i += 1)
{
const int &id = (ts.value(i) <= ts.value(i+1)) ? up : down;
tree->add(new Node(NULL, id, i, i+1, 0));
}
forest.push_back(tree);
result.treesAdded = 1;
result.nodesAdded = (ts.size() + 1) / 2;
}
catch (const EAnalyze &e)
{
m_lastError = e;
}
return result;
}
示例2:
template <typename TimeSeries> typename TimeSeries::value_type empirical_average(TimeSeries const &t) {
auto si = t.size();
if (si == 0) return typename TimeSeries::value_type{};
auto sum = t[0];
for (int i = 1; i < si; ++i) sum += t[i];
return sum / t.size();
}
示例3: decltype
template <typename TimeSeries> typename TimeSeries::value_type empirical_variance(TimeSeries const &t) {
auto si = t.size();
if (si == 0) return typename TimeSeries::value_type{};
auto avg = empirical_average(t);
decltype(avg) sum2 = (t[0] - avg) * (t[0] - avg); // also valid if t[0] is an array e.g., i.e. no trivial contructor...
for (int i = 1; i < si; ++i) sum2 += (t[i] - avg) * (t[i] - avg);
return sum2 / t.size();
}
示例4: binned
binned_series(TimeSeries const& t, int bin_size_)
: bin_size(bin_size_), binned(t.size() / bin_size_, value_type{}) {
if (bin_size_ > t.size())
TRIQS_RUNTIME_ERROR << "bin size (" << bin_size_ << ") cannot be larger than size (" << t.size() << ") of time series";
for (int i = 0; i < size(); i++) {
for (int j = 0; j < bin_size; j++) binned[i] += t[i * bin_size + j];
binned[i] /= bin_size;
}
}
示例5: blocker
Datum blocker(const RealMatrix& Ua, const RealMatrix sa, const vGroup& ensemble, const uint blocksize, uint repeats, ExtractPolicy& policy) {
TimeSeries<double> coverlaps;
for (uint i=0; i<repeats; ++i) {
vector<uint> picks = pickFrames(ensemble.size(), blocksize);
if (debug) {
cerr << "***Block " << blocksize << ", replica " << i << ", picks " << picks.size() << endl;
dumpPicks(picks);
}
vGroup subset = subgroup(ensemble, picks);
boost::tuple<RealMatrix, RealMatrix> pca_result = pca(subset, policy);
RealMatrix s = boost::get<0>(pca_result);
RealMatrix U = boost::get<1>(pca_result);
if (length_normalize)
for (uint j=0; j<s.rows(); ++j)
s[j] /= blocksize;
coverlaps.push_back(covarianceOverlap(sa, Ua, s, U));
}
return( Datum(coverlaps.average(), coverlaps.variance(), coverlaps.size()) );
}
示例6: EuclideanDistance
MOTIF_BEGIN
inline double EuclideanDistance(TimeSeries &t1, TimeSeries &t2, string name)
{
double dist = 0.0;
if(t1.size() != t2.size())
{
cout << t1.size() << "," << t2.size() << endl;
cout << "Called by " << name << endl;
system("pause");
}
for(size_t i = 0; i < t1.size(); ++i)
{
dist += pow(t1[i] - t2[i], 2.0);
}
return sqrt(dist);
}
示例7:
std::vector<Real> IntervalPrice::extractValues(
const TimeSeries<IntervalPrice>& ts,
IntervalPrice::Type t) {
std::vector<Real> returnval;
returnval.reserve(ts.size());
for (TimeSeries<IntervalPrice>::const_iterator i = ts.begin();
i != ts.end(); ++i) {
returnval.push_back(i->second.value(t));
}
return returnval;
}
示例8: operator
BIGDECIMAL maxval::operator() (TimeSeries& timeSeries)
{
int size = timeSeries.size();
BIGDECIMAL currentMax = -10000000000000.0;
for(int i = 0 ; i < size ; i++ )
{
if(timeSeries[i].val() > currentMax)
{
currentMax = timeSeries[i].val();
}
}
return currentMax ;
}
示例9:
TimeSeries<Volatility>
ConstantEstimator::calculate(const TimeSeries<Volatility>& volatilitySeries) {
TimeSeries<Volatility> retval;
const std::vector<Volatility> u = volatilitySeries.values();
TimeSeries<Volatility>::const_iterator prev, next, cur, start;
cur = volatilitySeries.begin();
std::advance(cur, size_);
// ICK. This could probably be made a lot more efficient
for (Size i=size_; i < volatilitySeries.size(); i++) {
Size j;
Real sumu2=0.0, sumu=0.0;
for (j=i-size_; j <i; j++) {
sumu += u[j];
sumu2 += u[j]*u[j];
}
Real s = std::sqrt(sumu2/(Real)size_ - sumu*sumu / (Real) size_ /
(Real) (size_+1));
retval[cur->first] = s;
++cur;
}
return retval;
}
示例10: save
bool FileCSV::save(const std::string &fileName, TimeSeries &ts)
{
std::ofstream file(fileName.c_str());
if (!file.is_open())
return false;
// Write header
for (unsigned int i = 0; i < ts.header().size(); ++i)
{
file << ts.header()[i];
if (i < ts.header().size() - 1)
file << m_separator;
}
// Write data
for (int row = 0; row < ts.size(); ++row)
{
file << std::endl << ts.time(row) << m_separator << ts.value(row);
}
file << std::endl;
file.close();
return true;
}
示例12: logp
double NSSKF::logp(const TimeSeries<DoubleData> & ts)const{
initialize();
double ans = 0;
for(uint i=0; i<ts.size(); ++i) ans += update(ts[i]->value());
return ans;
}