From fe474aa63f0751a48899121d461f47f0f0bcb1f6 Mon Sep 17 00:00:00 2001 From: RossTheRoss Date: Mon, 25 Feb 2019 17:04:29 +0000 Subject: A hack is the best kind of fix --- ee1301/wk3/hw3_directory/strap012_HW3A.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'ee1301') diff --git a/ee1301/wk3/hw3_directory/strap012_HW3A.cpp b/ee1301/wk3/hw3_directory/strap012_HW3A.cpp index 8d75294..e9701ff 100644 --- a/ee1301/wk3/hw3_directory/strap012_HW3A.cpp +++ b/ee1301/wk3/hw3_directory/strap012_HW3A.cpp @@ -12,7 +12,6 @@ One-armed Bandit Simulator #include #include #include -#include using namespace std; int spin_the_wheel(int d, int w) { @@ -21,7 +20,7 @@ int spin_the_wheel(int d, int w) { for (int i=0; i0; n--) { + for (long long n=1000000; n>0; n--) { int test = spin_the_wheel(d, w); m+=test; } double win=m; - cout << fixed << setprecision(5) - << "w=" << w << ", d=" << d - << ": Simulated probability = m/n = " << (win / 1000000.0) * 100.0 << "%. " + cout << "w=" << w << ", d=" << d + << ": Simulated probability = m/n = " << (win / 100000.0) * 100.0 << "%. " << "Theoretical probability = " << (d / (pow(d, w))) * 100 << "%." << endl; d+=2; } -- cgit v1.2.3