This repository has been archived on 2026-03-18. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
2026-03-18 22:48:20 -07:00

54 lines
2.0 KiB
Python

import numpy as np
import scipy.stats as s
import glob as glob # glob
import pandas as pd
filelist = glob.glob("hw3_*.txt")
filelist.sort()
def read(file):
fileobj = open(file, "r")
outputstr = fileobj.readlines()
fileobj.close()
outputarray = np.zeros(len(outputstr))
for i in np.arange(len(outputstr)):
outputarray[i] = float(outputstr[i])
return outputarray
# parameters = ["mean", "median", "std", "iqr", "skew", "kurtosis"]
# for i in range(len(filelist)):
# print(filelist[i])
# for n, param in enumerate(parameters):
# np_function = getattr(np, param)
# result = np_function(read(filelist[n]))
# print(result)
for n in range(len(filelist)):
print(filelist[n])
mean = np.mean(read(filelist[n]))
print("mean: " + str(mean))
median = np.median(read(filelist[n]))
print("median: " + str(median))
stddev = np.std(read(filelist[n]))
print("stddev: " + str(stddev))
iqr = s.iqr(read(filelist[n]))
print("iqr: " + str(iqr))
skew = s.skew(read(filelist[n]))
print("skew: " + str(skew))
kurtosis = s.kurtosis(read(filelist[n]))
print("kurtosis: " + str(kurtosis)+"\n")
# the mean and median are similar for all files, indicating solid, outlier free data.
# standard deviation is quite high for everything except wind shear, indicating either \
# inconsistent readings for everything but wind shear, or more likely, smaller units and \
# higher rates of change.
# the difference between shr1's iqr and stddev is larger than that of shr2's (shr2's is \
# quite close to its stddev), possibility of one minor outlier
# none of the data is very skewed, the largest (absolute value) being 0.54896, and \
# all of the data has negative kurtosis, meaning when distibuted, it will have a shallower \
# peak than the bell curve (e^x^2)
# the february and may datasets are similar in that their wind shears are similar, though \
# mays is still larger. they are different in that mays SRH and CAPE are both much higher, \
# so mays tornadoes are much stronger.