Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/python-basic-stats-leegivhan.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions stats_machine.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# import zcount
import csv
import statszcw

with open('dataOne.csv') as csv_file:
csv_reader = csv.reader(csv_file, delimiter=',')
line_count = 0
x = list()
y = list()
for row in csv_reader:
if line_count == 0:
# print(row[0])
line_count += 1
else:
x.append(float(row[0]))
y.append(float(row[1]))

print(x)
print(y)

print(statszcw.zcount(x))
print(statszcw.zcount(y))
# Count of X
# def stats_machine(x):
# zcount()
10 changes: 10 additions & 0 deletions statszcw/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# from statszcw.zcount import zcount
# from statszcw.zcorr import zcorr
# from statszcw import zmean
# from statszcw.zmedian import zmedian
# from statszcw.zmode import zmode
# from statszcw.zstddev import zstddev
# from statszcw.zstderr import zstderr
# from statszcw.zvariance import zvariance

# __all__ = ['zcount', 'zcorr', 'zmean', 'zmode', 'zmedian', 'zstddev', 'zstderr', 'zvariance']
21 changes: 21 additions & 0 deletions statszcw/zcorr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from statszcw import zcount
from statszcw import zstddev
from statszcw import zmean

def zcorr(list, list2) -> float:
"""
Calculates the correlation between two lists of values
:param list: list of values
:param list2: list of values
:return: float rounded to 2 decimal places
"""

sum = 0
for i in range(0, zcount.zcount(list)):
sum += ((list[i] - zmean.zmean(list)) * (list2[i]-zmean.zmean(list2)))
cov = sum / (zcount.zcount(list)-1)
corr = cov / (zstddev.zstddev(list) * zstddev.zstddev(list2))
return round(corr, 2)

if __name__ == "__main__":
print(zcorr([1, 2, 3, 2, 2, 3],[1, 1, 3, 2, 1, 3]))
19 changes: 19 additions & 0 deletions statszcw/zcount.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
def zcount(list) -> float:
"""
returns the number of elements in a list
:param list: list of elements
:return: int representing number of elements in given list
"""
c = 0
for _ in list:
c += 1
return c

if __name__ == "__main__":
print(zcount([1,2,3,4]))
# - zmode(list: List[]) -> float
# - zmedian(list: List[]) -> float
# - zvariance(list: List[]) -> float
# - zstddev(list: List[]) -> float
# - zstderr(list: List[]) -> float
# - zcorr(listx: List[], listy: List[]) -> float
17 changes: 17 additions & 0 deletions statszcw/zmean.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from statszcw import zcount

def zmean(list) -> float:
"""
Returns mean of given list
:param list: list
:return: float
"""
mean = sum(list) / zcount.zcount(list)
return float(mean)
# mean_list = 0
# for i in list:
# mean_list += i
# mean = mean_list / zcount(list)
# return mean
if __name__ == "__main__":
print(zmean([1, 2, 3, 4, 2, 2, 3]))
20 changes: 20 additions & 0 deletions statszcw/zmedian.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from statszcw import zcount

def zmedian(list) -> float:
"""
finds median value of given list
:param list: list of values
:return: float or int
"""
list.sort()
if len(list) % 2 != 0:
return list[(int(zcount(list)/2))]
elif len(list) % 2 == 0:
return (list[(int(zcount(list)/2))] + list[(int(zcount(list)/2))-1]) / 2

if __name__ == "__main__":
print(zmedian([1, 2, 3, 2, 2, 3]))
# print(zmedian([1, 6, 2, 3, 7, 2, 2, 3]))
# listo = [1, 2, 3, 2, 2, 3]
#
# print((listo[(int(len(listo)/2))] + listo[(int(len(listo)/2))-1])/2)
23 changes: 23 additions & 0 deletions statszcw/zmode.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
def zmode(list) -> float:
"""Finds mode of given list
:param list: list of values
:return: int, float, None if no mode, or list if multiple modes"""
# mode = 0
# mode_count = 0
for i in list:
mode_count = 0
mode = 0
# index = 0
for i in list:
if list.count(i) > mode_count:
mode_count = list.count(i)
mode = i
return mode

if __name__ == "__main__":
print(zmode([1, 2, 3, 4, 2, 2, 3]))

# mode_count += 1
# index += 1


16 changes: 16 additions & 0 deletions statszcw/zstddev.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from statszcw import zvariance
import math

def zstddev(list) -> float:
"""
Calculates standard deviation of given list
:param list: list of values
:return: float rounded to 5 decimal places
"""

var = zvariance.zvariance(list)
std_dev = math.sqrt(var)
return std_dev

if __name__ == "__main__":
print(zstddev([1, 2, 3, 4, 2, 2, 3]))
14 changes: 14 additions & 0 deletions statszcw/zstderr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from statszcw import zstddev
from statszcw import zcount
import math

def zstderr(list) -> float:
"""
Calculates standard error of mean of given list
:param list: list of values
:return: float rounded to 5 decimal places
"""
return zstddev.zstddev(list) / math.sqrt(zcount.zcount(list))

if __name__ == "__main__":
print(zstderr([3, 5, 2, 10, 1, 3]))
35 changes: 35 additions & 0 deletions statszcw/zvariance.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from statszcw import zmean, zcount
# from statszcw import zcount

def zvariance(list_in) -> float:
"""
Finds variance of given list
:param list: list of values
:return: float
"""

# Amanda
var_top = 0
data_mean = zmean.zmean(list_in)
# print(data_mean)
for val in list_in:
diff = float(val) - data_mean
sq_diff = diff ** 2
var_top += sq_diff
count_val = zcount.zcount(list_in) - 1
var = var_top / count_val
return float(var)

# Derek
# n = zcount(list)
# mean = zmean(list)
# d = [(x - mean) ** 2 for x in list]
# v = sum(d) / (n - 1)
# return round(v, 5)

# Anusha
# mean = zmean.zmean(list)
# return sum((x - mean) ** 2 for x in list) / zcount.zcount(list)

if __name__ == "__main__":
print(zvariance([3, 5, 2, 10, 1, 3]))