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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started