added interface for walkers
some new helper methods added interpolater for paths
This commit is contained in:
@@ -1,54 +0,0 @@
|
||||
#ifndef EXPONENTIAL_H
|
||||
#define EXPONENTIAL_H
|
||||
|
||||
#include <cmath>
|
||||
#include <random>
|
||||
|
||||
namespace Distribution {
|
||||
|
||||
template <typename T> class Exponential {
|
||||
|
||||
private:
|
||||
|
||||
T lambda;
|
||||
|
||||
std::minstd_rand gen;
|
||||
std::exponential_distribution<T> dist;
|
||||
|
||||
public:
|
||||
|
||||
/** ctor */
|
||||
Exponential(const T lambda) : lambda(lambda), gen(1234), dist(lambda) {
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
/** get probability for the given value */
|
||||
T getProbability(const T val) const {
|
||||
return lambda * std::exp(-lambda * val);
|
||||
}
|
||||
|
||||
/** get a normally distributed random number */
|
||||
T draw() {
|
||||
return dist(gen);
|
||||
}
|
||||
|
||||
/** set the seed to use */
|
||||
void setSeed(const long seed) {
|
||||
gen.seed(seed);
|
||||
}
|
||||
|
||||
|
||||
/** get the probability for the given value */
|
||||
static double getProbability(const double lambda, const double val) {
|
||||
return lambda * std::exp(-lambda * val);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // EXPONENTIAL_H
|
||||
Reference in New Issue
Block a user