41 #ifndef _RANDOMTOOLS_H_ 42 #define _RANDOMTOOLS_H_ 45 #include "../VectorExceptions.h" 46 #include "../VectorTools.h" 47 #include "../../Exceptions.h" 120 template<
class intType>
130 static void setSeed(
long seed);
186 size_t pos = RandomTools::giveIntRandomNumberBetweenZeroAndEntry<size_t>(v.size());
201 size_t pos = RandomTools::giveIntRandomNumberBetweenZeroAndEntry<size_t>(v.size());
225 if (vout.size() > vin.size() && !replace)
227 std::vector<size_t> hat(vin.size());
228 for (
size_t i = 0 ; i < vin.size() ; i++)
230 for (
size_t i = 0 ; i < vout.size() ; i++)
231 vout[i] = vin[
pickOne(hat, replace)];
259 size_t pos = v.size() - 1;
260 for (
size_t i = 0; i < v.size(); ++i) {
261 if (prob < sumw[i]) {
305 if (vout.size() > vin.size() && !replace)
306 throw IndexOutOfBoundsException(
"RandomTools::getSample (with weights): size exceeded v.size.", vout.size(), 0, vin.size());
307 std::vector<size_t> hat(vin.size());
308 for (
size_t i = 0 ; i < vin.size() ; i++)
310 std::vector<double> w2(w);
311 for (
size_t i = 0 ; i < vout.size() ; i++)
312 vout[i] = vin[
pickOne(hat, w2, replace)];
325 static std::vector<size_t>
randMultinomial(
size_t n,
const std::vector<double>& probs);
352 static double qNorm(
double prob);
373 static double qNorm(
double prob,
double mu,
double sigma);
386 static double lnGamma (
double alpha);
404 static double incompleteGamma(
double x,
double alpha,
double ln_gamma_alpha);
421 static double qChisq(
double prob,
double v);
433 return pGamma(x, v / 2, 0.5);
444 static double qGamma(
double prob,
double alpha,
double beta)
446 return qChisq(prob,2.0*(alpha))/(2.0*(beta));
461 if (alpha < 0)
throw Exception(
"RandomTools::pGamma. Negative alpha is not allowed.");
462 if (beta < 0)
throw Exception(
"RandomTools::pGamma. Negative beta is not allowed.");
463 if (alpha == 0.)
return 1.;
488 static double pNorm(
double z);
500 static double pNorm(
double z,
double mu,
double sigma);
513 static double lnBeta (
double alpha,
double beta);
528 static double incompleteBeta(
double x,
double alpha,
double beta);
529 static double pBeta(
double x,
double alpha,
double beta)
547 static double qBeta(
double prob,
double alpha,
double beta);
558 #endif //_RANDOMTOOLS_H_
This class allows to perform a correspondence analysis.
This is the interface for the Random Number Generators.
Exception thrown when an empty vector was found.
Index out of bounds exception class.