From cc26093e45cbd492fdd7a0db8c21a9b5e82f19e0 Mon Sep 17 00:00:00 2001 From: RossTheRoss Date: Tue, 26 Feb 2019 14:09:10 -0600 Subject: Fix A because I'm an idiot --- ee1301/wk3/hw3_directory/strap012_HW3A.cpp | 14 +++++++------- 1 file changed, 7 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 9aacf63..f83132d 100644 --- a/ee1301/wk3/hw3_directory/strap012_HW3A.cpp +++ b/ee1301/wk3/hw3_directory/strap012_HW3A.cpp @@ -24,6 +24,7 @@ using namespace std; int spin_the_wheel(int d, int w) { int spinOG=0, spinNew=0, win=0; spinOG = ( (rand() % d) + 1); //Original spin is always the same + w-=1; for (int i=0; i0; n--) { int winTest = spin_the_wheel(d, w); - m+=winTest; + winCount+=winTest; } - double win=m; cout << "w=" << w << ", d=" << d - << ": Simulated probability = m/n = " << (win / 100000.0) * 100.0 << "%. " //Note that 100,000!=1,000,000 - << "Theoretical probability = " << (d / (pow(d, w))) * 100 << "%." << endl; //This is because otherwise the percentage was off by a factor of 10 + << ": Simulated probability = m/n = " << (winCount / 1000000.0) * 100.0 << "%. " + << "Theoretical probability = " << (d / (pow(d, w))) * 100 << "%." << endl; d+=2; } } -- cgit v1.2.3