Advertisement
Guest User

Untitled

a guest
Oct 12th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #include <vector>
  2. #include <random>
  3. #include <iostream>
  4. int main()
  5. {
  6. std::vector<double> estimation;
  7. int simulation_length = 1000000;
  8. std::default_random_engine generator;
  9. std::normal_distribution<double> distribution(100.0, 1.0);
  10. double pick;
  11. double estimation_sum;
  12.  
  13. for (int i = 0; i != simulation_length; ++i)
  14. {
  15. pick = distribution(generator);
  16. if (pick > 100)
  17. {
  18. estimation.push_back(exp(-100 * (pick - 100)));
  19. }
  20. }
  21.  
  22. for (double i : estimation)
  23. {
  24. estimation_sum += i;
  25. }
  26.  
  27. std::cout << estimation_sum / simulation_length << std::endl;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement