Hello coders, today we are going to solve **Day 6: The Central Limit Theorem I HackerRank Solution** which is a Part of **10 Days of Statistics** Series.

Contents

**Objective**

In this challenge, we practice solving problems based on the *Central Limit Theorem*.

**Task**

A large elevator can transport a maximum of **9800** pounds. Suppose a load of cargo containing **49** boxes must be transported via the elevator. The box weight of this type of cargo follows a distribution with a mean of** u = 205** pounds and a standard deviation of

**pounds. Based on this information, what is the probability that all**

*o*= 15**49**boxes can be safely loaded into the freight elevator and transported?

**Input Format**

There are **4** lines of input (shown below):

```
9800
49
205
15
```

The first line contains the maximum weight the elevator can transport. The second line contains the number of boxes in the cargo. The third line contains the mean weight of a cargo box, and the fourth line contains its standard deviation.

If you do not wish to read this information from stdin, you can hard-code it into your program.

**Output Format**

Print the probability that the elevator can successfully transport all **49** boxes, rounded to a scale of **4** decimal places (i.e., **1.2345** format).

**Solution – The Central Limit Theorem I**

**C++**

#include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> using namespace std; double normal_dist(double m, double sd, double x) { /* p = 1/2*(1 + erf((x - m)/(sd*sqrt(2)))); */ double p = 0.5*(1 + erf((x-m)/(sd*sqrt(2.0)))); return p; } int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ double m = 49*205, sd = sqrt(49)*15, x = 9800; printf("%0.4f", normal_dist(m, sd, x)); return 0; }

**Disclaimer:** The above Problem **(The Central Limit Theorem I) **is generated by **Hacker Rank** but the Solution is Provided by **CodingBroz**. This tutorial is only for **Educational** and** Learning** Purpose.