本文整理汇总了C++中TimeSeries::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ TimeSeries::begin方法的具体用法?C++ TimeSeries::begin怎么用?C++ TimeSeries::begin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeSeries
的用法示例。
在下文中一共展示了TimeSeries::begin方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testConstruction
void TimeSeriesTest::testConstruction() {
BOOST_MESSAGE("Testing time series construction...");
TimeSeries<Real> ts;
ts[Date(25, March, 2005)] = 1.2;
ts[Date(29, March, 2005)] = 2.3;
ts[Date(15, March, 2005)] = 0.3;
TimeSeries<Real>::const_iterator cur = ts.begin();
if (cur->first != Date(15, March, 2005)) {
BOOST_ERROR("date does not match");
}
if (cur->second != 0.3) {
BOOST_ERROR("value does not match");
}
ts[Date(15, March, 2005)] = 4.0;
cur = ts.begin();
if (cur->second != 4.0) {
BOOST_ERROR("replaced value does not match" << cur->second << "\n");
}
ts[Date(15, March, 2005)] = 3.5;
if (cur->second != 3.5) {
BOOST_ERROR("set value operator not match" << cur->second << "\n");
}
}
示例2: HammingDistance
// Compute HammingDistance between two time series
size_t NTuple::HammingDistance( TimeSeries& t1, TimeSeries& t2 )
{
size_t h = 0;
TimeSeriesIter iter1 = t1.begin();
TimeSeriesIter iter2 = t2.begin();
while( iter1 != t1.end() && iter2 != t2.end() )
{
// Accumulate the Hamming distance for each NTuple
h += *iter1++ - *iter2++;
}
return h;
}
示例3:
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;
}
示例4: Iterate
// Iterate only the k'th variable with respect to the given reference time series
size_t DynSysModel::Iterate( TimeSeries& ref_series, size_t k, TimeSeries& result, size_t kov )
{
// Make sure the result is empty
result.clear();
// Hamming distance for bit k
size_t h = 0;
TimeSeriesIter t_iter = ref_series.begin();
// Empty series in => empty series out
if( t_iter == ref_series.end() ) return h;
// Save the initial state as the first state in the result
mState = *t_iter;
// Force the knockout variable to zero - no longer needed, corrected when file is read in
// if( kov != 0 ) mState.Reset(kov);
result.push_back( mState );
bool f;
while( true )
{
// Merge the next state from the time series with the function evaluation
// (a) increment iterator and check for end of time series
++t_iter;
if( t_iter == ref_series.end() ) break;
// Evaluate the k'th polynomial at the current state
// to produce a new value for the k'th variable for time i+1
f = mModel[k-1].Evaluate( mState );
// (b) assign value pointed to by iterator to mState (t[i+1])
mState = *t_iter;
// Force the knockout variable to zero - no longer needed, corrected when file is read in
// if( kov != 0 ) mState.Reset(kov);
// Accumulate Hamming Distance = t'[i+1][k] - t[i+1][k]
h += (mState[k] ^ f) ? 1 : 0;
// (c) create t'[i+1] = t[i+1] with k'th element replaced by f(t'[i])
mState.Assign( k, f );
// Save t'[i+1]
result.push_back( mState );
}
return h;
}
示例5:
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;
}