Question

how to calculate standard deviation in python without any packages and functions except len(). And ensure...

how to calculate standard deviation in python without any packages and functions except len(). And ensure the outcome is same as the output from r function sd().

Homework Answers

Answer #1

Answer

Here is your python script ,if you have any doubt please comment, i am here to help you.

Here we know that, we can calculate the standard deviation as follows.

So here i will take one population [32,111,138,28,59,77,97], this standard deviation is 37.84501153334721.

So here i implemented the code for finding standard deviation without any package in python.

Here is the code

data = [32,111,138,28,59,77,97]  #list of population 
sum=0  #sum initially zero
length=len(data) #finding the length of population 
for i in data:
    sum=sum+i      #total sum of the population
mean=sum/length   #mean=total_sum/number of items
variance=0
for i in data:
    variance=variance+((i-mean)**2/length) #finding variance
standard_deviation=variance**(1/2)  #square root of the variance is SD.
print(str(standard_deviation))

output

Any doubt please comment ,

Thanks in advance

Know the answer?
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
Similar Questions
When we create an array of values and calculate the standard deviation of the array in...
When we create an array of values and calculate the standard deviation of the array in R (using sd() function) and Python (using std() function from NumPy package.), think and give an explanation why the results are different
Please do it in Python Write the simplest program that will demonstrate iteration vs recursion using...
Please do it in Python Write the simplest program that will demonstrate iteration vs recursion using the following guidelines - Write two primary helper functions - one iterative (IsArrayPrimeIter) and one recursive (IsArrayPrimeRecur) - each of which Take the array and its size as input params and return a bool. Print out a message "Entering <function_name>" as the first statement of each function. Perform the code to test whether every element of the array is a Prime number. Print out...
write a code in python Write the following functions below based on their comments. Note Pass...
write a code in python Write the following functions below based on their comments. Note Pass is a key word you can use to have a function the does not do anything. You are only allowed to use what was discussed in the lectures, labs and assignments, and there is no need to import any libraries. #!/usr/bin/python3 #(1 Mark) This function will take in a string of digits and check to see if all the digits in the string are...
1. A normal distribution has a mean of 105.0 and a standard deviation of 18.0. Calculate...
1. A normal distribution has a mean of 105.0 and a standard deviation of 18.0. Calculate the Z score that you would use in order to find the probability P(X>111.0) 2. A statistical experiment involves recording the number of times a light blinks during intervals of varied durations. Historically, the light blinks at a rate of 5.1 times per minute on average. Calculate the probability that in a randomly selected 5.5-minute interval, the light blinks 31 times. 3. Consider a...
What is the meaning of variance and standard deviation? (I understand how to calculate them, but...
What is the meaning of variance and standard deviation? (I understand how to calculate them, but understanding the concept behind them is confusing.) What happens if the variance calculated is the same as them mean? What is the meaning behind these numbers? For example, you roll a 6 sided dice and each possibility is equally likely. Then both the mean and variance is 3.5.
Question (2) [5 marks] (Use R) Suppose you have a company producing cupcakes. Each cupcake is...
Question (2) [5 marks] (Use R) Suppose you have a company producing cupcakes. Each cupcake is supposed to contain 10 grams of sugar. The cupcakes are produced by a machine that adds the sugar in a bowl before mixing everything. You believe the machine does not add 10 grams of sugar for each cupcake. If your assumption is true, the machine needs to be fixed. You stored the level of sugar of thirty cupcakes. Note: You can create a randomized...
Assignment III 1) Use the non-machine formula to calculate the variance and standard deviation from the...
Assignment III 1) Use the non-machine formula to calculate the variance and standard deviation from the following data Herd 1 67 62 69 72 68 68 71 69 65 71 70 64 64 66 71 67 75 2) What is the probability that one card selected from a deck of 52 is a club or a number card or both? 3) A container contains 10 green tennis balls and 7 orange tennis balls. What is the probability of drawing 2...
Write a Python program named lastNameVolumes that finds the volumes of different 3 D objects such...
Write a Python program named lastNameVolumes that finds the volumes of different 3 D objects such as a cube, sphere, cylinder and cone. In this file there should be four methods defined. Write a method named cubeVolFirstName, which accepts the side of a cube in inches as an argument into the function. The method should calculate the volume of a cube in cubic inches and return the volume. The formula for calculating the volume of a cube is given below....
Please create a python module named homework.py and implement the functions outlined below. Below you will...
Please create a python module named homework.py and implement the functions outlined below. Below you will find an explanation for each function you need to implement. When you are done please upload the file homework.py to Grader Than. Please get started as soon as possible on this assignment. This assignment has many problems, it may take you longer than normal to complete this assignment. This assignment is supposed to test you on your understanding of reading and writing to a...
Use python language please #One of the early common methods for encrypting text was the #Playfair...
Use python language please #One of the early common methods for encrypting text was the #Playfair cipher. You can read more about the Playfair cipher #here: https://en.wikipedia.org/wiki/Playfair_cipher # #The Playfair cipher starts with a 5x5 matrix of letters, #such as this one: # # D A V I O # Y N E R B # C F G H K # L M P Q S # T U W X Z # #To fit the 26-letter alphabet into...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT