-
Notifications
You must be signed in to change notification settings - Fork 0
/
day6_3
33 lines (27 loc) · 1.09 KB
/
day6_3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//In this challenge, we practice solving problems based on the Central Limit Theorem.//
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
float const errorFunction(const float stdDev, const float zScore, const int population)
{
float stdErr = stdDev/sqrt(population);
return stdErr*zScore;
}
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT
You have a sample of 100 values from a population with mean 500 and with standard deviation 80.
Compute the interval that covers the middle of the 95% distribution of the sample mean; in other words, compute A and B such that P(A < x < B)=0.95.
Use the z-value of 1.96. */
const int mean = 500;
const int stdDev = 80;
const float zScore = 1.96;
const int population = 100;
float lowerSum = mean - errorFunction(stdDev, zScore, population);
float higherSum = mean + errorFunction(stdDev, zScore, population);
cout << fixed << setprecision(2) << lowerSum << endl << higherSum;
return 0;
}