Jan-22-2018, 11:56 PM

SO I am having a hard time trying to calculate the standard deviation given the graph. I was wondering what the steps were? Here is a code of what I have so far, but is not getting the right output. the DataSet contains thousands of random numbers such as:

9.8254457980e-1 1.0293906530e+0 8.6314178340e-1 8.7754757930e-1 8.2216021950e-1 9.8155318390e-1 1.0215753050e+0 1.0064994180e+0 1.0300426240e+0 8.7195144970e-1 9.4140464140e-1 1.0811751280e+0 8.5982980390e-1

#Worksheet 1.3A - make plot of DataSet vs row Nums

from numpy import *

from matplotlib.pyplot import *

import matplotlib.pyplot as plt

--------------------------------------------------------------

# Import data as a list of numbers

with open("DataSet1.dat", "r") as textFile:

data = textFile.read().split() # split based on spaces

data = [float(point) for point in data] # convert strings to floats

rms = 0

#This is my code for calculating the square of the deviation

sqrt_rms = square(rms)

variance = average([square(i) for i in textFile]) - average1**2

print("The square of the standard deviation is:", variance)

print("The standard deviation is:", sqrt(variance))

#^Would square root of variance calculate the standard deviation?

plt.xlabel('x axis')

plt.ylabel('y axis')

plt.title('Plot of DataSet vs Row Numbers')

plt.plot(data)

plt.show()

9.8254457980e-1 1.0293906530e+0 8.6314178340e-1 8.7754757930e-1 8.2216021950e-1 9.8155318390e-1 1.0215753050e+0 1.0064994180e+0 1.0300426240e+0 8.7195144970e-1 9.4140464140e-1 1.0811751280e+0 8.5982980390e-1

#Worksheet 1.3A - make plot of DataSet vs row Nums

from numpy import *

from matplotlib.pyplot import *

import matplotlib.pyplot as plt

--------------------------------------------------------------

# Import data as a list of numbers

with open("DataSet1.dat", "r") as textFile:

data = textFile.read().split() # split based on spaces

data = [float(point) for point in data] # convert strings to floats

rms = 0

#This is my code for calculating the square of the deviation

sqrt_rms = square(rms)

variance = average([square(i) for i in textFile]) - average1**2

print("The square of the standard deviation is:", variance)

print("The standard deviation is:", sqrt(variance))

#^Would square root of variance calculate the standard deviation?

plt.xlabel('x axis')

plt.ylabel('y axis')

plt.title('Plot of DataSet vs Row Numbers')

plt.plot(data)

plt.show()