In this lab, you will write code to compute some statistics of a dataset. Mean a
ID: 3698581 • Letter: I
Question
In this lab, you will write code to compute some statistics of a dataset. Mean and variance are important measures that give valuable information about a dataset. Note that today you are creating your own functions and docstrings and test data, which is part of the exercise. Please write docstrings carefully using the 103 style guide, (which are also followed in the code I provide each lectur Relevant lectures: lecture 19 and 20 1. Write a function to coinpute the mean ? of a list of integers L of length n: L[0]+.. + Ln-1 Motivation: we are assuming that each element of L occurs with equal probability so we are weighting each one by ? 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; if the variance of L is V then the standard deviation is D=VV Grading: Code for mean, variance, and standard deviation. If and when you complete the above, please proceed with the following experiment. This will prepare you for Monte Carlo simulations. 1. write a function to toss a fair coin; t 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 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 E (0,1 of headsExplanation / Answer
%please ask remaining questions again,we have to answer 1 at a time, i did 3 def mean(L): ''' function to calculate and return mean of a list of integers :param L:list of integers :return: mean of the integers in L ''' return sum(L)/len(L) def variance(L): ''' function to calculate Variance of a list of integers :param L: list of integers :return: Variance of the integers in L ''' s=0 mu=mean(L) for i in L: s=s+(i-mu)**2 return s/len(L) def standardDeviation(L): ''' function to calculate standard deviation of a list of integers :param L: list of integers :return: standard deviation of integers in L ''' return (variance(L))**(.5)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.