当前位置: 首页>>代码示例>>C++>>正文


C++ TimeSeries::size方法代码示例

本文整理汇总了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;
}
开发者ID:onurak,项目名称:fractal-analysis,代码行数:29,代码来源:AB.cpp

示例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();
 }
开发者ID:TRIQS,项目名称:triqs,代码行数:7,代码来源:statistics.hpp

示例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();
    }
开发者ID:TRIQS,项目名称:triqs,代码行数:9,代码来源:statistics.hpp

示例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;
  }
 }
开发者ID:JaksaVucicevic,项目名称:triqs,代码行数:9,代码来源:statistics.hpp

示例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()) );

}
开发者ID:GrossfieldLab,项目名称:loos,代码行数:29,代码来源:boot_bcom.cpp

示例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);
}
开发者ID:markatango,项目名称:otsm,代码行数:20,代码来源:motif.cpp

示例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;
 }
开发者ID:grantathon,项目名称:nquantlib64,代码行数:11,代码来源:prices.cpp

示例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 ;
}
开发者ID:danielkoh,项目名称:quantserver,代码行数:14,代码来源:maxval.cpp

示例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;
 }
开发者ID:21hub,项目名称:QuantLib,代码行数:22,代码来源:constantestimator.cpp

示例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;
}
开发者ID:onurak,项目名称:fractal-analysis,代码行数:24,代码来源:FileCSV.cpp

示例11: size

 int size() const { return ts.size(); }
开发者ID:TRIQS,项目名称:triqs,代码行数:1,代码来源:statistics.hpp

示例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;
}
开发者ID:Hkey1,项目名称:boom,代码行数:6,代码来源:NoStorageScalarKalmanFilter.cpp


注:本文中的TimeSeries::size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。