// -------------------------------------------------- double RngBoost::gammaSample(double a, double b) const { static boost::uniform_01<boost::mt19937> zeroone(m_rng); boost::math::gamma_distribution<double> gamma_dist(a,b); return quantile(gamma_dist, zeroone()); }
double SMPUtilities::rand01() { boost::mt19937 rng; static boost::uniform_01<boost::mt19937> zeroone(rng); double p = zeroone(); return p; }
// -------------------------------------------------- double RngBoost::betaSample(double alpha, double beta) const { static boost::uniform_01<boost::mt19937> zeroone(m_rng); boost::math::beta_distribution<double> beta_dist(alpha, beta); return quantile(beta_dist, zeroone()); }
// -------------------------------------------------- double RngBoost::gaussianSample(double stdDev) const { double mean = 0.; //it will be added conveniently later static boost::uniform_01<boost::mt19937> zeroone(m_rng); boost::math::normal_distribution<double> gaussian_dist(mean, stdDev); return quantile(gaussian_dist, zeroone()); }
core::MonteCarloMoverResult RelativePositionMover::do_propose() { last_transformation_ = rbA_.get_reference_frame().get_transformation_to(); ::boost::uniform_real<> zeroone(0., 1.); double p = zeroone(random_number_generator); if (p < probability_of_random_move_) { algebra::Vector3D translation = algebra::get_random_vector_in( algebra::Sphere3D(rbA_.get_coordinates(), max_translation_)); algebra::Vector3D axis = algebra::get_random_vector_on( algebra::Sphere3D(algebra::Vector3D(0.0, 0.0, 0.0), 1.)); ::boost::uniform_real<> rand(-max_angle_, max_angle_); Float angle = rand(random_number_generator); algebra::Rotation3D r = algebra::get_rotation_about_axis(axis, angle); algebra::Rotation3D rc = r * rbA_.get_reference_frame().get_transformation_to().get_rotation(); algebra::Transformation3D t(rc, translation); IMP_LOG_TERSE("proposing a random move " << t << std::endl); // std::cout << "proposing a random move for " << rbA_->get_name() << " " // << rbA_ << " Transformation " << t << std::endl; rbA_.set_reference_frame(algebra::ReferenceFrame3D(t)); } else { ::boost::uniform_int<> randi(0, reference_rbs_.size() - 1); unsigned int i = randi(random_number_generator); ::boost::uniform_int<> randj(0, transformations_map_[i].size() - 1); unsigned int j = randj(random_number_generator); algebra::Transformation3D Tint = transformations_map_[i][j]; IMP_LOG_TERSE("proposing a relative move. Rigid body " << i << "Internal transformation " << j << " " << Tint << std::endl); // std::cout << "Proposing a relative move. Rigid body " << // rbA_->get_name() // << " " << rbA_ << " Relative transformation " << Tint<< std::endl; // core::RigidBody rb = reference_rbs_[i]; algebra::Transformation3D T_reference = reference_rbs_[i].get_reference_frame().get_transformation_to(); // std::cout << "RF receptor ===> " << T_reference << std::endl; // new absolute reference frame for the rigid body of the ligand algebra::Transformation3D Tdock = algebra::compose(T_reference, Tint); rbA_.set_reference_frame(algebra::ReferenceFrame3D(Tdock)); // std::cout << "Finished proposing. Reference frame for the ligand" // << rbA_.get_reference_frame() << std::endl; } return core::MonteCarloMoverResult( ParticleIndexes(1, rbA_.get_particle_index()), 1.0); }
void TestLinearBasisFunction2d() { ChastePoint<2> zero(0,0); ChastePoint<2> onezero(1,0); ChastePoint<2> zeroone(0,1); std::vector<ChastePoint<2>*> evaluation_points; evaluation_points.push_back(&zero); evaluation_points.push_back(&onezero); evaluation_points.push_back(&zeroone); BasisFunctionsCheckers<2> checker; checker.checkLinearBasisFunctions(evaluation_points); // Derivatives c_matrix<double, 2, 3> derivatives; LinearBasisFunction<2>::ComputeBasisFunctionDerivatives(onezero,derivatives); TS_ASSERT_DELTA(derivatives(0,0), -1, 1e-12); TS_ASSERT_DELTA(derivatives(0,1), 1, 1e-12); TS_ASSERT_DELTA(derivatives(0,2), 0, 1e-12); }
// -------------------------------------------------- double RngBoost::uniformSample() const { static boost::uniform_01<boost::mt19937> zeroone(m_rng); return zeroone(); }
double drand48(void) { boost::rand48 rng; static boost::uniform_01<boost::rand48> zeroone(rng); return zeroone(); }