Question

In: Computer Science

Write the python code that generates a normal sample with given μ and σ, and the...

Write the python code that generates a normal sample with given μ and σ, and the code that calculates m and s from the sample. Do the same using the Bayes’ estimator assuming a prior distribution for μ.

Solutions

Expert Solution

#source code:

import numpy as np
mue=5 #here mue value i took 5
sigma=0.1 #here i took sigma value=0.1
sample_count=100
sample=np.random.normal(mue,sigma,sample_count)
print("Sample Data Generated:\n",sample) #here ganerate sample data

print("Mean(M value):",np.mean(sample)) #calculate the mue value based on sample data geneated
print("Standard Deviation(S value):",np.std(sample)) #calculate the sigma value based on sample data

#bayes:
check=lambda k:np.random.normal(5,0.1,k)
fun=check(100)
print("sample Data:\n",fun)
print("Mean",np.mean(fun))
print("Std",np.std(fun))


#output:

#if you have any doubt comment below...


Related Solutions

Write the python code that generates a normal sample with given μ and σ, and the...
Write the python code that generates a normal sample with given μ and σ, and the code that calculates m (sample mean) and s (sample standard deviation) from the sample.
Given a normal distribution with μ=103 and σ=25​, and given you select a sample of n=25​,...
Given a normal distribution with μ=103 and σ=25​, and given you select a sample of n=25​, complete parts​ (a) through​ (d). What is the probability that X is between 91 and 93.5​? ​P(91<X<93.5​)=
1. Given a normal distribution with μ=102 and σ=25, if you select a sample of n=12,...
1. Given a normal distribution with μ=102 and σ=25, if you select a sample of n=12, what is the probability that ?̅ is a. less than 90 ? b. between 90 and 92.5 ? c. above 103.6 ? 2. Given a normal distribution with μ=101 and σ=15, if you select a sample of n=9, what is the probability that ?̅ is a. less than 95 ? b. between 90 and 92.5 ? c. above 101.8 ?
Given a normal distribution with μ=40 and σ =9​, find​ (a) the normal curve area to...
Given a normal distribution with μ=40 and σ =9​, find​ (a) the normal curve area to the right of x=25; (b) the normal curve area to the left of x=29; (c) the normal curve area between x=43 and x=52​; (d) the value of x that has 90​% of the normal curve area to the​ left; and​ (e) the two values of x that contain the middle 70​% of the normal curve area.
Given a normal distribution with μ=40 and σ=66​, find​ (a) the normal curve area to the...
Given a normal distribution with μ=40 and σ=66​, find​ (a) the normal curve area to the right of x=24; (b) the normal curve area to the left of x=29; (c) the normal curve area between x=47 and x=54; ​(d) the value of x that has 70​% of the normal curve area to the​ left; and​ (e) the two values of x that contain the middle 65​% of the normal curve area.
Given that x is a normal variable with mean μ = 49 and standard deviation σ...
Given that x is a normal variable with mean μ = 49 and standard deviation σ = 6.2, find the following probabilities. (Round your answers to four decimal places.) (a)  P(x ≤ 60) (b)  P(x ≥ 50) (c)  P(50 ≤ x ≤ 60)
Given that x is a normal variable with mean μ = 43 and standard deviation σ...
Given that x is a normal variable with mean μ = 43 and standard deviation σ = 6.9, find the following probabilities. (Round your answers to four decimal places.) (a) P(x ≤ 60) (b) P(x ≥ 50) (c) P(50 ≤ x ≤ 60)
Given that x is a normal variable with mean μ = 107 and standard deviation σ...
Given that x is a normal variable with mean μ = 107 and standard deviation σ = 11, find the following probabilities. (Round your answers to four decimal places.) (a)  P(x ≤ 120) (b)  P(x ≥ 80) (c)  P(108 ≤ x ≤ 117)
Given that x is a normal variable with mean μ = 49 and standard deviation σ...
Given that x is a normal variable with mean μ = 49 and standard deviation σ = 6.9, find the following probabilities. (Round your answers to four decimal places.) (a)  P(x ≤ 60) (b)  P(x ≥ 50) (c)  P(50 ≤ x ≤ 60)
Given that x is a normal variable with mean μ = 108 and standard deviation σ...
Given that x is a normal variable with mean μ = 108 and standard deviation σ = 14, find the following probabilities. (Round your answers to four decimal places.) (a) P(x ≤ 120) (b) P(x ≥ 80) (c) P(108 ≤ x ≤ 117)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT