1
0
mirror of https://github.com/aportelli/LatAnalyze.git synced 2025-06-20 16:26:54 +01:00

option to dump bootstrap sequence while resampling

This commit is contained in:
2017-10-02 11:54:12 +01:00
parent 3d514ef026
commit 98cf39efda
2 changed files with 32 additions and 1 deletions

View File

@ -47,6 +47,8 @@ public:
// resampling
Sample<T> bootstrapMean(const Index nSample, const SeedType seed);
Sample<T> bootstrapMean(const Index nSample);
void dumpBootstrapSeq(std::ostream &out, const Index nSample,
const SeedType seed);
private:
// mean from pointer vector for resampling
void ptVectorMean(T &m, const std::vector<const T *> &v);
@ -114,6 +116,23 @@ Sample<T> Dataset<T>::bootstrapMean(const Index nSample)
return bootstrapMean(nSample, rd());
}
template <typename T>
void Dataset<T>::dumpBootstrapSeq(std::ostream &out, const Index nSample,
const SeedType seed)
{
std::mt19937 gen(seed);
std::uniform_int_distribution<Index> dis(0, this->size() - 1);
for (Index i = 0; i < nSample; ++i)
{
for (unsigned int j = 0; j < this->size(); ++j)
{
out << dis(gen) << " " << std::endl;
}
out << std::endl;
}
}
template <typename T>
void Dataset<T>::ptVectorMean(T &m, const std::vector<const T *> &v)
{