// Produces a random K81 transition matrix with diagonal entries >= 0.7. void K81_random_edge(TMatrix &tm) { double a,b,c,d; double dmin = 0.7; do { a = uniform_real(dmin, 1); b = uniform_real(0, 1-dmin); c = uniform_real(0, 1-dmin); d = 1 - a - b - c; } while (d < 0); K81_matrix(a,b,c,d,tm); }
//This method executes the policy pair<vector<float>,float> CDACN::policy(const Window &window) { if(uniform_real(engine)<exploration_rate_ or not window.full()) return explore(); else return exploit(window); }
// Random K81 transition matrix for a given branch length void K81_random_edge_length(double len, TMatrix &tm) { double a,b,c,d; double K, x1, x2, x3, s, m, M, p, q; K = exp(-4*len); // s is the only real root of x(x+1)^2 - 4K = 0 s = - 2./3. + 1./3.*pow(1. + 54.*K + 6.*sqrt(3.*K + 81.*K*K), 1./3.) + 1./3.*pow(1. + 54.*K - 6.*sqrt(3.*K + 81.*K*K), 1./3.); if (s > 1 || s < 0) { std::cout << "Error: Something strange happened at K81_random_edge_length. Bad s."; std::cout << std::endl; } x1 = uniform_real(s, 1); p = sqrt((x1*(x1-1)*(x1-1)+4*K)/x1); q = sqrt((x1*(x1+1)*(x1+1)-4*K)/x1); m = 0.5*(x1 + std::max<double>(1-q, p-1)); M = 0.5*(1 + std::min<double>(p-x1, q+x1)); if (m > M || m < 0) { std::cout << "Error: Something strange happened at K81_random_edge_length: bad bounds m and M."; std::cout << std::endl; } x2 = uniform_real(m, M); double gamma; gamma = uniform_real(0,1); if (gamma > 0.5) x1 = -x1; gamma = uniform_real(0,1); if (gamma > 0.5) x2 = -x2; x3 = K/(x1*x2); b = 0.25*(1 - x1 - x2 + x3); c = 0.25*(1 - x1 + x2 - x3); d = 0.25*(1 + x1 - x2 - x3); a = 1 - b - c - d; K81_matrix(a,b,c,d,tm); }
fcppt::random::distribution::parameters::uniform_real< FloatType > fcppt::random::distribution::parameters::uniform_real< FloatType >::convert_to( distribution const &_dist ) { return uniform_real( min( fcppt::random::distribution::decorated_value( _dist.a() ) ), sup( fcppt::random::distribution::decorated_value( _dist.b() ) ) ); }