Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vector>
- #include <random>
- #include <iostream>
- int main()
- {
- std::vector<double> estimation;
- int simulation_length = 1000000;
- std::default_random_engine generator;
- std::normal_distribution<double> distribution(100.0, 1.0);
- double pick;
- double estimation_sum;
- for (int i = 0; i != simulation_length; ++i)
- {
- pick = distribution(generator);
- if (pick > 100)
- {
- estimation.push_back(exp(-100 * (pick - 100)));
- }
- }
- for (double i : estimation)
- {
- estimation_sum += i;
- }
- std::cout << estimation_sum / simulation_length << std::endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement