Question

Python Problem:

Problem 1: Computing variance For this problem, you will write a function variance that takes a list whose elements are numbe

Variance Explanation:

Clearly, these two data sets are very different. In the first, all the data points are clustered closely around the mean; in

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Python 3 code

============================================================================================

def variance(data):
mean=sum(data)/len(data)
total=0.0
for i in data:
total+=(i-mean)**2

return total/len(data)


example_data=[18,19,20,21,22]

try:
v=variance(example_data)
print(v)
except(ZeroDivisionError):
pass
  

============================================================================================

Output

variance_1.py - DyChega/python3.6codes/vanance_1.py 36.5) Eile Edit Format Run Options Window Help det variance (data) mean-s

Add a comment
Know the answer?
Add Answer to:
Python Problem: Variance Explanation: Problem 1: Computing variance For this problem, you will write a function...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Age, Deviation, Squared Deviation, Frequency, Frequency x Squared Deviation EXERCISE #2 You fill in the 3rd...

    Age, Deviation, Squared Deviation, Frequency, Frequency x Squared Deviation EXERCISE #2 You fill in the 3rd column of this table. The first entry is done for you. Commas are not necessary. Frequency Table for Data Set B Age (years) Frequency Age x Frequency 18 19 20 21 1782 105 45 31 12 28 10 15 16 1995 900 651 23 24 25 26 27 28 29 30 31 35 644 2 40 3 75 416 2 16 280 2 32...

  • 4- Variance and Standard deviation (how far the data values lie from the mean) The mean,...

    4- Variance and Standard deviation (how far the data values lie from the mean) The mean, mode, and median do a nice job in telling where the center of the data set is, but often we are interested in more. For example, a pharmaceutical engineer develops a new drug that regulates iron in the blood. Suppose she finds out that the average sugar content after taking the medication is the optimal level. This does not mean that the drug is...

  • The following are short Python calculations. Give the answer and the Python code for each. 1....

    The following are short Python calculations. Give the answer and the Python code for each. 1. What is the sum of the numbers from 22:100 incrementing by 2? Do this in two ways: Use a while statement and a for loop to do the calculation. (Hint: make sure the numbers include 100) 2. What is the mean, standard deviation of the square root of the numbers from 3 to 5 incrementing by 0.1? Use the linspace function from the numpy...

  • (b) Write a Ruby function sigma that uses your function mean and computes the standard deviation of an arbitrary number of arguments. Function calls sigma (1,2,1,2) , sigma (1) and sigma should r...

    (b) Write a Ruby function sigma that uses your function mean and computes the standard deviation of an arbitrary number of arguments. Function calls sigma (1,2,1,2) , sigma (1) and sigma should respectively return 1 ,0,and "No arguments". (Hint: the standard deviation is the square root o variance, and variance is the mean value of squares minus the square of the mean value) (c) Write a Ruby function stat that computes and returns the mean value, standard deviation, and the...

  • n du Consider the data set below: 22 12 21 22 S = 19 45 20...

    n du Consider the data set below: 22 12 21 22 S = 19 45 20 30 37 34 44 23 26 33 70 54 40 48 23 17 22 56 38 17 21 16 33 41 84 43 27 65 34 19 100 34 48 29 54 16 43 33 8934 43 31 37 77 43 43 Problem 1 (a) Make a stem and leaf display of S. (b) Calculate the mean I = 2 (c) Calculate the 10%-trimmed...

  • 4. (10pts)For each of the data set below, find the mean (i) and standard (1) (4pts)...

    4. (10pts)For each of the data set below, find the mean (i) and standard (1) (4pts) 10 (2) (4pts) 20 18 16 12 14 (3) (2pts) From the results of (1) and (2), what do you think the standard deviation is for the numbers (101, 103, 105, 107, 109)? (In generol, ony S consecutive even numbers or s numbers should have exactly the same stondard deviation, since their spread are of 2 (6pts) Mean is a measure of the center...

  • (a) Write a Ruby function mean that computes the mean value of an arbitrary number of arguments. Function calls mean (1,2,3,4,5) mean 3 ,1 ,and "No arguments". (1) and mean should respect...

    (a) Write a Ruby function mean that computes the mean value of an arbitrary number of arguments. Function calls mean (1,2,3,4,5) mean 3 ,1 ,and "No arguments". (1) and mean should respectively return tion sigma that uses your function mean and computes the standard deviation of an arbitrary of arguments. Function calls sigma (1,2,1,2)sigma (1) and sigma should respectively return1, o, and "No arguments" (Hint: the standard deviation is the square root of (b) Write a Ruby func variance, and...

  • Magic Square question for Python

    You have this solution in Java, I am interested in this same solution for Python.One interesting application of two-dimensional arrays is magic squares. A magic square is a square matrix in which the sum of every row, every column, and bothdiagonals is the same. Magic squares have been studied for many years, and there are some particularly famous magic squares. In this exercise you will write code todetermine whether a square is magic.You should find that the first, second, and...

  • USE THE PYTHON ONLY Sudoku Game Check Please write a Python program to check a Sudoku...

    USE THE PYTHON ONLY Sudoku Game Check Please write a Python program to check a Sudoku game and show its result in detail. This is an application program of using 2-dimensional arrays or lists. Each array or list is a game board of 9 x 9. Your program must check the 9 x 9 game board, and report all the problems among 9 rows, 9 columns, and 9 squares. As you can see, you must pre-load the following four games...

  • Write a Python function cardinality() that takes in three Python set objects, representing sets of between...

    Write a Python function cardinality() that takes in three Python set objects, representing sets of between 0 and 50 integers, AA, BB, and UU. Your function should return a single non-negative integer value for the cardinality of the set below. AA and BB are subsets (not necessarily proper) of the universal set UU. |P(A¯¯¯¯∩B)||P(A¯∩B)| Note 1: You can copy-paste the code declaring the various visible test cases below. We strongly encourage you to do this to test your code. Note...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT