Question

In 1181:from scipy import stats fron rath import sgrt Confidence Interval For a sample with size large enough, by central limit theorem we can assume its mean follows normal distribution. And if we also know the standard deviation of the population, we are able to calculate a confidence interval to estimate the population mean. Problem 1 A confidence interval is usually given by sample mean m plus and minus a margin of error r The contidence interval is larger (less precisel tor large contidence level, and smaller (more precise) for small contidence level. For this problam, you are askad to write a function Error that calculates the margin of error r given sample size , confidence level p and standard deviation of Im-rm +r the population s. Code: Error (40,0.95,20) Error (40,0.95, 10) Output 6.1979503230456140 3.0989751615228074 In 1191:modify this cell def Error (n,D,8) inputs: sample size n, confidence level p and standard deviations output: margin of error r YOUR CODE HERE in [47]1 Check function assert aba(Error(60,0.9,20)-.2469938027546128) <10+-5 assert aba(Error(60,0.9,10)-2.123496901377306) 10+-5 # AUTOGRADER TEST-DO NOT REMOVE Problem 2 For this problem, you are asked to write a function confidence that calculates the confidence level deviation of the population s given sample size n, margin of error , and standard Code: Confidenc40, 6,20) Confidence40,8,20) Output 0.98858796361399826 in 148] ! # modify this coll dot confidenc이 n , r·s) : # inputs: sample sizo ne margin of error r, and st ndard deviation s # output: conf įdnce level r # YOUR CODE HERE In [49]: # Check Function assert abs (Confidence (60,5,20)-0.94719248858388649) 10^*-5 assert abs (Confidence (60,6,20)-0-97986324844965367) 10-5 AUTOGRADER TEST-DO NOT REMOVE

0 0
Add a comment Improve this question Transcribed image text
Answer #1

from scipy import stats
from math import sqrt

Problem 1:

def Error(n, p, s):
z = stats.norm.ppf(1-(1-p)/2)
moe = z * s / sqrt(n)
return moe

Problem 2:

def Confidence(n, r, s):
z = r * sqrt(n) / s
v = stats.norm.cdf(z)
p = 1 - 2 * (1 - v)
return p

Add a comment
Know the answer?
Add Answer to:
In 1181:from scipy import stats fron rath import sgrt Confidence Interval For a sample with size...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a function in R that will provide the sample size needed (using the confidence interval...

    Write a function in R that will provide the sample size needed (using the confidence interval method) to estimate the true population mean. You will have to pass several input variables to this function: confidence level, margin of error, and estimated standard deviation.

  • Given the confidence interval for a mean of (74.5738,77.4262), from a sample of size 34 with...

    Given the confidence interval for a mean of (74.5738,77.4262), from a sample of size 34 with a population standard deviation of σ=3.6, find the following: Margin of Error(ME)= Standard Error(SE)= Zc= what was the confidence level for this confidence interval?= (Show your work please)

  • How will increasing the sample size without changing the level of confidence affect the width of...

    How will increasing the sample size without changing the level of confidence affect the width of a confidence interval for a population mean? Assume that the population standard deviation is unknown and the population distribution is approximately normal. Select your answer from the choices below. The margin of error will increase because the critical value will increase and the sample size, n, is located in the denominator of the formula for margin of error. The increased margin of error will...

  • Determine the sample size needed to construct a 95% confidence interval to estimate the average GPA...

    Determine the sample size needed to construct a 95% confidence interval to estimate the average GPA for the student population at a college with a margin of error equal to 0.2. Assume the standard deviation of the GPA for the student population is 25 The sample size needed is (Round up to the nearest integer.) Determine the sample size n needed to construct a 90% confidence interval to estimate the population proportion for the following sample proportions when the margin...

  • Here is an example with steps you can follow: sample size n=9, sample mean=80, sample standard...

    Here is an example with steps you can follow: sample size n=9, sample mean=80, sample standard deviation s=25 (population standard deviation is not known) Estimate confidence interval for population mean with confidence level 90%. Confidence Interval = Sample Mean ± Margin of Error Margin of Error = (t-value)×s/√n t-value should be taken from Appendix Table IV. For n=9 df=n-1=9-1=8 For Confidence Level 90% a = 1 - 0.90 = 0.10, a/2 = 0.10/2 = 0.05 So, we are looking for...

  • Which statement about a confidence interval estimate of is true? A. Increasing the sample size decreases...

    Which statement about a confidence interval estimate of is true? A. Increasing the sample size decreases the error margin. B. Increasing the level of confidence decreases the error margin. OC. Decreasing the error margin makes the confidence interval wider. OD. Increasing the population mean increases the error margin, QUESTION 10 The fishing industry is interested in the mean weight of salmon caught by a certain fishing company. From previous years' data, the standard deviation of the weights of salmon caught...

  • 11, a A simple random sample of size n is drawn from a population that is...

    11, a A simple random sample of size n is drawn from a population that is normally distributed. The sample​ mean, x overbarx​, is found to be 102​, and the sample standard​ deviation, s, is found to be 10. ​(a) Construct a 96​% confidence interval about muμ if the sample​ size, n, is 24. ​(b) Construct a 96​% confidence interval about muμ if the sample​ size, n, is 17. ​(c) Construct a 90​% confidence interval about muμ if the sample​...

  • Determine the sample size needed to construct a 99% confidence interval to estimate the average GPA...

    Determine the sample size needed to construct a 99% confidence interval to estimate the average GPA for the student population at a college with a margin of error equal to 0.7. Assume the standard deviation of the GPA for the student population is 1.0 The sample size needed is _____

  • a sample size of _ is needed So there a 99% confidence interval will have a...

    a sample size of _ is needed So there a 99% confidence interval will have a margin of error of three.so there a 99% confidence interval will have a margin of error of three. 1. simple random sample of 100 2. mean was 125 hours 3. standard deviation is 20 hours.

  • What sample size is needed to obtain a 95% confidence interval whose margin of error is...

    What sample size is needed to obtain a 95% confidence interval whose margin of error is no more than 1.7 for the mean of a normal population with standard deviation 4.5?

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT