Created
June 26, 2020 12:39
-
-
Save carlopi/1f064cbcf283e7a87413d99ead4862f2 to your computer and use it in GitHub Desktop.
normalDistribution.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <random> | |
auto getSeed() | |
{ | |
//I am not JSExported! | |
std::random_device rd; | |
return rd(); | |
} | |
class [[cheerp::jsexport]] NormalDistribution { | |
public: | |
NormalDistribution() : gen(getSeed()), dist() {} | |
double generate() { | |
return dist(gen); | |
} | |
private: | |
std::mt19937 gen; | |
std::normal_distribution<> dist; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment