part 1 1. Write a function to compute the mean ? of a list of integers L of leng
ID: 3698767 • Letter: P
Question
part 1
1. Write a function to compute the mean ? of a list of integers L of length n.
2. Write a function to compute the variance V of a list of integers L of length n.
This measures the spread or dispersion of the data.
3. Write a function to compute the standard deviation D of a list of integers L
part 2
1. write a function to toss a fair coin; it should return True if the coin toss yields Heads and False if the
coin toss yields Tails.
2. write a function to toss a fair coin 100 times and count the number of heads; (we will call this an
experiment)
3. write a function to repeat this experiment 1000 times, and compute the mean of the # of heads
4. compute the standard deviation of these experiments
Repeat this exercise for a biased coin, with probability
p ? [0,1] of heads.
Explanation / Answer
Solution:
part 1:
1)
function:
def calcAverage(numbers): #Method to calculate the average iof the elements which are in the given array
sum= 0
average= 0.0
2)
function:
def VarianceD(numbers):
average= calcAverage(numbers)
I hope this helps if you find any problem. Please comment below. Don't forget to give a thumbs up if you liked it. :)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.