aboutsummaryrefslogtreecommitdiffstats
path: root/eval/src/tests/ann/std-random.h
blob: d0b81151ebf5b34fc7cbadacc405bad8e8c6e9e5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once
#include <random>

class RndGen {
private:
    std::mt19937_64 urng;
    std::normal_distribution<double> normRng;
    std::uniform_real_distribution<double> uf;
public:
    RndGen() : urng(0x1234deadbeef5678uLL), normRng(), uf(0.0, 1.0) {}

    double nextNormal() {
        return normRng(urng);
    }

    double nextUniform() {
        return uf(urng);
    }
};