34 lines
746 B
Python
34 lines
746 B
Python
|
#!/usr/bin/env python
|
||
|
# -*- coding: utf-8 -*-
|
||
|
|
||
|
import numpy as np
|
||
|
|
||
|
with open("./dane.txt") as ff:
|
||
|
x = [int(line.strip()) for line in ff]
|
||
|
|
||
|
print(np.mean(x))
|
||
|
print(np.var(x))
|
||
|
|
||
|
print(min(x))
|
||
|
print(max(x))
|
||
|
|
||
|
x_scaled = [(i - min(x)) / (max(x) - min(x)) for i in x]
|
||
|
print(min(x_scaled), max(x_scaled))
|
||
|
|
||
|
def normalize(data):
|
||
|
return [(i - np.mean(x)) / np.sqrt(np.var(x)) for i in data]
|
||
|
|
||
|
normalized = normalize(x)
|
||
|
|
||
|
print(np.mean(normalized), np.var(normalized))
|
||
|
|
||
|
x_binned = [i // 10 for i in x]
|
||
|
|
||
|
|
||
|
for begin in range(0, 1 + max(x_binned)):
|
||
|
if begin == 0:
|
||
|
print("[ ", 10 * begin, ", ", 10 * begin + 9, "]", "+" * x_binned.count(begin))
|
||
|
else:
|
||
|
print("[", 10 * begin, ",", 10 * begin + 9, "]", "+" * x_binned.count(begin))
|
||
|
|