Challenge: Normal Distribution #3
Subdomeniu: Probability (probability)
Scor cont: 5.0 / 5
Submission status: Accepted
Submission score: 1.0
Submission ID: 464719021
Limbaj: python3
Link challenge: https://www.hackerrank.com/challenges/normal-distribution-3/problem
Cerinta
A large group of students took a test in physics and the final grades have a mean of 70 and a standard deviation of 10. If we can approximate the distribution of these grades by a normal distribution, what percent of the students
a) scored higher than 80?
b) should pass the test (grades≥60)?
c) should fail the test (grades<60)?
**Submission Modes and Output Format**
You may submit either an R or Python program to accomplish the above task or solve the problem on pen-and-paper. Your output should be three floating point/decimal numbers separated by a line, correct to 2 places of decimal.
1. In the text box below, enter three floating point/decimal numbers, correct to 2 places of decimal.
2. Alternatively, you may submit an R program, which uses the above parameters (hard-coded) and computes the answer.
Your answer should resemble something like:
<pre>
65.12
15.45
2.78
</pre>
(This is **NOT** the answer, just a demonstration of what the answering format should resemble).
Cod sursa
# Enter your code here. Read input from STDIN. Print output to STDOUT
import math
def get_function(x):
mu = 70
sig = 10
gaussian_func = (1 / (sig * math.sqrt(2 * math.pi))) * math.exp(-((x - mu) ** 2) / (2 * sig ** 2))
return gaussian_func
start_value = 20
end_value = 120
step = 0.0001
x = [start_value + i * step for i in range(int((end_value - start_value) / step) + 1)]
y0 = 0
y1 = 0
y2 = 0
y3 = 0
for i in range(len(x)):
y0 += get_function(x[i]) * step
if x[i] > 80:
y1 += get_function(x[i]) * step
if x[i] >= 60:
y2 += get_function(x[i]) * step
if x[i] < 60:
y3 += get_function(x[i]) * step
y1 = y1 * 100 / y0
y2 = y2 * 100 / y0
y3 = y3 * 100 / y0
result1 = round(y1, 2)
result2 = round(y2, 2)
result3 = round(y3, 2)
print(str(result1))
print(str(result2))
print(str(result3))
HackerRank Probability – Normal Distribution #3
