Question

In: Computer Science

  Question no 3: USE PYTHON a. Generate a discrete uniform distribution of population size 100 between...

  Question no 3: USE PYTHON

a. Generate a discrete uniform distribution of population size 100 between interval (1,10).)

b Consider the sample size of N=10, Simulate the sampling distribution of the sample mean. (repeat 100 times)

c Consider the sample size of N=30, what is the sample mean and sample standard deviation? (repeat 100 times)

Solutions

Expert Solution

a. Generate a discrete uniform distribution of population size 100 between interval (1,10).
Solution for part A:

import random

array = [random.randint(1,10) for i in range (100)]

This will produce a uniform distribution of size 100 with values between 1 and 10

b Consider the sample size of N=10, Simulate the sampling distribution of the sample mean. (repeat 100 times)

The simulation of sampling distribution of sample mean showing 100 histogram for each sampling:

import random
import statistics
import matplotlib.pyplot as plt

array = [random.randint(1, 10) for i in range(100)]
print(array)

for i in range(100):
    random.shuffle(array)
    mean = sum(array[:10]) / 10
    result = plt.hist(array[0:10], bins=20, color='c', edgecolor='k', alpha=0.65)
    plt.axvline(statistics.mean(array[0:10]), color='k', linestyle='dashed', linewidth=1)
    plt.show()

c Consider the sample size of N=30, what is the sample mean and sample standard deviation? (repeat 100 times)

The following program will take 30 samples 100 time and each time print the mean and standard deviation.

import random
import statistics

array = [random.randint(1, 10) for i in range(100)]
print(array)

for i in range(100):
    random.shuffle(array)
    sample_mean = sum(array[:30]) / 30
    standard_dev=statistics.stdev(array[:30])
    print("The mean of sample size of 30 is {} and its standard deviation is {}".format("%.2f" % sample_mean,"%.2f" % standard_dev))

Related Solutions

Generate 100 samples of size n=8 from an exponential distribution with mean 3 . Each row...
Generate 100 samples of size n=8 from an exponential distribution with mean 3 . Each row of your data will denote an observed random sample of size 8, from an exponential distribution with mean 3. Obtain sample mean for each sample, store in another column and make a histogram for sample means. Repeat for n=100. Compare and interpret the histograms you obtained for n=8 and n=100. Submit the histograms along with your one small paragraph comparison. Can you solve it...
Consider a sample of size 100 drawn from a population that obeys an unknown distribution. It...
Consider a sample of size 100 drawn from a population that obeys an unknown distribution. It is known that the population-variance (of some quality characteristic) is 6. Let µ denote the population-mean. Consider the following test of a hypothesis about µ. H0 : µ = 70 H1 : µ ≠ 70 (a) Calculate Z0.005. Explain the meaning of Z0.005. (b) If the sample mean is observed to be 71, would you reject H0 with 99% confidence? What is the p-value...
Use Math.random function to generate a number between 20 and 100 and then use the ngSwitch...
Use Math.random function to generate a number between 20 and 100 and then use the ngSwitch directive to display a letter grade based on this class grading policy. add implements OnInit to the AppComponent class add variable x in the AppComponent class add ngOnInit(){ this.x = Math.floor(Math.random()*10);} add {{x}} in the app.components.html file You should see numbers from 1-9 when you refresh the page Change formula in #c to generate numbers from 20 to 100. Change {{x}} in #d to...
a. Generate samples of size 25, 50, 100 from a normal distribution. Construct probability plots. Do...
a. Generate samples of size 25, 50, 100 from a normal distribution. Construct probability plots. Do this several times to get an idea of how probability plots behave when the underlying distribution is really normal. b. Repeat part (a) for a chi-square distribution with 10 df I am required to use the R statistical program and I do not understand how to use it to solve this problem. If you could please show me the R Stats needed to solve...
Q1. Uniform Distribution You believe stock price will follow uniform distribution with mean of 100 and...
Q1. Uniform Distribution You believe stock price will follow uniform distribution with mean of 100 and MAD 20. You are pricing a CALL option with strike at 110. a. what is the mean and range of the distribution? b. what is the probability that the call will be ITM at expiration (ie stock price ends above strike at 110)? c. what is the conditional mean of stock price when CALL is ITM (aka stock price is above strike 110)? d....
Uniform Distribution You believe stock price will follow uniform distribution with mean of 100 and MAD...
Uniform Distribution You believe stock price will follow uniform distribution with mean of 100 and MAD 20. You are pricing a CALL option with strike at 110. a. what is the range of the distribution? b. what is the probability that the call will be ITM at expiration (ie stock price ends above strike at 110)? c. what is the conditional mean of stock price when CALL is ITM (aka stock price is above strike 110)? d. what is the...
7) Use Excel to generate a series of 100 random values from the exponential distribution with...
7) Use Excel to generate a series of 100 random values from the exponential distribution with a mean of 25? USING EXCEL SHOW ALL WORK
This question is based on a Poisson discrete probability distribution. The distribution is important in biology...
This question is based on a Poisson discrete probability distribution. The distribution is important in biology and medicine, and can be dealt with in the same way as any other discrete distribution. Red blood cell deficiency may be determined by examining a specimen of blood under the microscope. The data in Table B gives a hypothetical distribution of numbers of red blood cells in a certain small fixed volume of blood from normal patients. Theoretically, there is no upper limit...
Given the following discrete uniform probability distribution, find the expected value and standard deviation of the...
Given the following discrete uniform probability distribution, find the expected value and standard deviation of the random variable. Round your final answer to three decimal places, if necessary. Probability Distribution x 0 1 2 3 4 5 6 7 8 9 10 P(X=x) 1/11 1/11 1/11 1/11 1/11 1/11 1/11 1/11 1/11 1/11 1/11
Write the R code to generate five independent uniform random numbers and use that to generate...
Write the R code to generate five independent uniform random numbers and use that to generate 5 independent Bernoulli random variables with probability of success p = 0.4. please use RStudio. please do not use lab nor rbern for calculations.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT