Question: An online algorithm for computing the sample mean and variance starts with x _n=0 and s_n^2=0 , where x _n,s_n^2, are the sample mean and

An online algorithm for computing the sample mean and variance starts with x _n=0 and s_n^2=0 , where x _n,s_n^2, are the sample mean and variance for points, respectfully. Then, for each new sample point, the quantities are updated using the following formulas:

x _n= x _(n-1)+(x _n-x _(n-1))/n

and

s_n^2=(n-2)/(n-1) s_(n-1)^2+((x_n-x _(n-1) )^2)/n for (n>1)

Requirements You are to create a program using Python that asks the user for a nonnegative number, then computes the mean and variance using the above given formulas which should be displayed on the console screen. The program should end when a user enters a negative number.

Additional Requirements

1. The name of your source code file should be OnlineStats.py. All your code should be within a single file.

2. Your code should follow good coding practices, including good use of whitespace and use of both inline and block comments.

3. You need to use meaningful identifier names that conform to standard naming conventions.

4. At the top of each file, you need to put in a block comment with the following information: your name, date, course name, semester, and assignment name.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!