Skip to content

Instantly share code, notes, and snippets.

@carlopi
Created June 26, 2020 12:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlopi/1f064cbcf283e7a87413d99ead4862f2 to your computer and use it in GitHub Desktop.
Save carlopi/1f064cbcf283e7a87413d99ead4862f2 to your computer and use it in GitHub Desktop.
normalDistribution.cpp
#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