diff options
| author | KunoiSayami <[email protected]> | 2022-06-20 16:15:34 +0800 |
|---|---|---|
| committer | KunoiSayami <[email protected]> | 2022-06-20 16:15:34 +0800 |
| commit | 85296957a8d755cda80c5dc00dcef4555ff14ebc (patch) | |
| tree | 2de6d0d4f7aaef5eff0eec7a98b5e39376fca83c /normal_distribution.cpp | |
| parent | e0fa8c3a324f0b8b155058d4f05ea69a4df1f5bf (diff) | |
fix(script): Fix normal distribution generator
* feat(script): Add p.d.f. and c.d.f. painter
Signed-off-by: KunoiSayami <[email protected]>
Diffstat (limited to 'normal_distribution.cpp')
| -rw-r--r-- | normal_distribution.cpp | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/normal_distribution.cpp b/normal_distribution.cpp index c9cf701..fd52ac1 100644 --- a/normal_distribution.cpp +++ b/normal_distribution.cpp @@ -1,6 +1,11 @@ #include <algorithm> #include <cstdio> #include <random> +#include <set> +#include <vector> + +constexpr size_t length = 1048576; + int main() { std::random_device randomDevice; @@ -8,9 +13,21 @@ int main() { std::normal_distribution<long double> normalDistribution(2147483647, 2147483647); - for (int i = 0; i < 1048576; i++) { - printf("%llu\n", - (unsigned long long)std::round(normalDistribution(randomEngine))); + std::set<long long> set; + + std::vector<long long> vector; + + vector.reserve(length); + + while (set.size() != length) { + auto element = (long long)std::round(normalDistribution(randomEngine)); + auto ret = set.insert(element); + if (ret.second) + vector.push_back(element); + } + + for (long long element : vector) { + printf("%lld\n", element); } return 0; |
