本文整理汇总了C++中DSSpikeEvent::set_offset方法的典型用法代码示例。如果您正苦于以下问题:C++ DSSpikeEvent::set_offset方法的具体用法?C++ DSSpikeEvent::set_offset怎么用?C++ DSSpikeEvent::set_offset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DSSpikeEvent
的用法示例。
在下文中一共展示了DSSpikeEvent::set_offset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
void
nest::poisson_generator_ps::event_hook( DSSpikeEvent& e )
{
// get port number
const port prt = e.get_port();
// we handle only one port here, get reference to vector elem
assert( 0 <= prt && static_cast< size_t >( prt ) < B_.next_spike_.size() );
// obtain rng
librandom::RngPtr rng = net_->get_rng( get_thread() );
// introduce nextspk as a shorthand
Buffers_::SpikeTime& nextspk = B_.next_spike_[ prt ];
if ( nextspk.first.is_neg_inf() )
{
// need to initialize relative to t_min_active_
// first spike is drawn from backward recurrence time to initialize the process in equilibrium.
// In the case of the Poisson process with dead time, this has two domains:
// one with uniform probability (t<dead_time) and one
// with exponential probability (t>=dead_time).
// First we draw a uniform number to choose the case according to the associated probability
// mass.
// If dead_time==0 we do not want to draw addtional random numbers (keeps old functionality).
double spike_offset = 0;
if ( P_.dead_time_ > 0 and rng->drand() < P_.dead_time_ * P_.rate_ / 1000.0 )
{
// uniform case: spike occurs with uniform probability in [0, dead_time].
spike_offset = rng->drand() * P_.dead_time_;
}
else
{
// exponential case: spike occurs with exponential probability in [dead_time, infinity]
spike_offset = V_.inv_rate_ms_ * V_.exp_dev_( rng ) + P_.dead_time_;
}
// spike_offset is now time from t_min_active_ til first spike.
// Split into stamp+offset, then add t_min_active.
nextspk.first = Time::ms_stamp( spike_offset );
nextspk.second = nextspk.first.get_ms() - spike_offset;
nextspk.first += V_.t_min_active_;
}
// as long as there are spikes in active period, emit and redraw
while ( nextspk.first <= V_.t_max_active_ )
{
// std::cerr << nextspk.first << '\t' << nextspk.second << '\n';
e.set_stamp( nextspk.first );
e.set_offset( nextspk.second );
e.get_receiver().handle( e );
// Draw time of next spike
// Time of spike relative to current nextspk.first stamp
const double new_offset =
-nextspk.second + V_.inv_rate_ms_ * V_.exp_dev_( rng ) + P_.dead_time_;
if ( new_offset < 0 ) // still in same stamp
nextspk.second = -new_offset; // stamps always 0 < stamp <= h
else
{
// split into stamp and offset, then add to old stamp
const Time delta_stamp = Time::ms_stamp( new_offset );
nextspk.first += delta_stamp;
nextspk.second = delta_stamp.get_ms() - new_offset;
}
}
// std::cerr << "********************************\n";
}