void CFakeSensor::read() { // Generate a random variation on temperature (+/- 0 to 1.0°) auto offset = static_cast<int>(m_dist(m_gen) - 10.0) / 10.0; // Random offset, value from -1.0 to 1.0 auto temperature = m_temperature1->get() + offset; //we keep 2 decimals m_temperature1->set(static_cast<int>(temperature * 100) / 100.0); // Generate a random variation on temperature (+/- 0 to 2.0°) offset = static_cast<int>(m_dist(m_gen) - 20.0) / 20.0; // Random offset, value from -2.0 to 2.0 temperature = m_temperature2->get() + offset; //we keep 2 decimals m_temperature2->set(static_cast<int>(temperature * 100) / 100.0); // Decrease battery level (min 20%) if (m_batteryLevel->get() > 20) m_batteryLevel->set(m_batteryLevel->get() - 1); //set the current date time onto m_datetime keyword m_dateTime->set(shared::currentTime::Provider().now()); // Generate a random variation on temperature (+/- 0 to 1°) offset = static_cast<int>(m_dist(m_gen) - 10.0) / 10.0; // Random offset, value from -1.0 to 1.0 auto current = m_current->get() + offset; if (current < 0) current = 0; if (current > 5) current = 5; m_current->set(static_cast<int>(current * 10) / 10.0); }
matrix_eig EigenUtil::PairwiseEuclideanDist(const matrix_eig &m1, const matrix_eig &m2) { matrix_eig m_dist(m1.rows(), m2.rows()); for (int i = 0; i < m1.rows(); i++) { for (int j = 0; j < m2.rows(); j++) { m_dist(i, j) = (m1.row(i) - m2.row(j)).norm(); } } return m_dist; }
ExpiryTimerImpl::Id ExpiryTimerImpl::generateId() { Id newId = m_dist(m_mt); std::lock_guard< std::mutex > lock{ m_mutex }; while (newId == INVALID_ID || containsId(newId)) { newId = m_dist(m_mt); } return newId; }
box sample_point(box b) { static thread_local std::mt19937_64 rg(std::chrono::system_clock::now().time_since_epoch().count()); unsigned const n = b.size(); ibex::IntervalVector & values = b.get_values(); for (unsigned i = 0; i < n; i++) { ibex::Interval & iv = values[i]; double const lb = iv.lb(); double const ub = iv.ub(); if (lb != ub) { std::uniform_real_distribution<double> m_dist(lb, ub); iv = ibex::Interval(m_dist(rg)); } } return b; }
box box::sample_point() const { static mt19937_64 rg(system_clock::now().time_since_epoch().count()); unsigned const n = size(); box b(*this); ibex::IntervalVector const & values = get_values(); for (unsigned i = 0; i < n; i++) { ibex::Interval const & iv = values[i]; double const lb = iv.lb(); double const ub = iv.ub(); if (lb != ub) { uniform_real_distribution<double> m_dist(lb, ub); b[i] = ibex::Interval(m_dist(rg)); } } return b; }
int_type allocate( size_t N ) { typedef typename distribution_type::param_type param_type; m_dist.param( param_type( m_mut_rate.m_mu * N ) ); return m_dist( *m_rand ); }
bool random_icp::random_bool() { static thread_local std::mt19937_64 rg(std::chrono::system_clock::now().time_since_epoch().count()); std::uniform_real_distribution<double> m_dist(0, 1); return m_dist(rg) >= 0.5; }
result_type operator()( unsigned int age = 0) { unsigned int nEvents = m_dist(*m_rng); return result_type( m_mgen, nEvents, age ); }
double BernouilliGenerator::operator()() { return m_dist(m_engine); }
position_type operator()( Engine & eng ) { return m_dist( eng ); }
position_type operator()() { return m_dist( *m_rand ); }
std::pair< node_type , size_t > get_node( rng_type& rng ) const { return generate( rng , m_generators[ m_dist( rng ) ] ); }
int Random::next(int min, int max) { resetRange(min, max); return m_dist(m_rnd); }
//----------------------------------------------------------------------------// // Generation Methods // //----------------------------------------------------------------------------// int Random::next() { resetRange(0, std::numeric_limits<int>::max()); return m_dist(m_rnd); }