Soluție HackerRank pentru Day 4: Normal Distribution #1, subdomeniul Probability, în Python 3. Include cerința formatată, exemple, explicația pașilor și…
- Problemă: Day 4: Normal Distribution #1
- Domeniu: Probability
- Limbaj: Python 3
Challenge: Day 4: Normal Distribution #1
Subdomeniu: Probability (probability)
Scor cont: 5.0 / 5
Submission status: Accepted
Submission score: 1.0
Submission ID: 464717812
Limbaj: python3
Link challenge: https://www.hackerrank.com/challenges/normal-distribution-1/problem
Cerință
Objective
In this challenge, we practice solving problems with normally distributed variables.
Task
X is a normally distributed variable with a mean of μ = 30 and a standard deviation of σ = 4. Find:
- P(x < 40)
- P(x > 21)
- P(30 < x < 35)
Output Format
Your output must be a floating point/decimal number, correct to a scale of 3 decimal places. You can submit solutions in either of the 2 following ways:
1. Solve the problem manually and submit your result as *Plain Text*. In the text box below, enter 3 lines of floating point/decimal numbers.
2. Submit an *R* or *Python* program, which uses the above parameters (hard-coded), and computes the answer.
Your answer should resemble something like:
0.123
0.456
0.789
(This is NOT the answer, just a demonstration of the answering format.)
Cod sursă
import math
mu = 30
sig = 4
def cdf(x):
return math.erfc((mu-x)/(sig*math.sqrt(2)))/2
print(cdf(40))
print(1 - cdf(21))
print(cdf(35)-cdf(30))
