forked from sysprog21/fibdrv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot.py
53 lines (43 loc) · 1.36 KB
/
plot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# -*- coding: utf-8 -*-
"""plot.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/15jIaKbufsRWgmJ7BWyCQqxSf5PgXN2ps
"""
from google.colab import drive
drive.mount('/gdrive')
# Commented out IPython magic to ensure Python compatibility.
# %cd /gdrive/MyDrive/Linux
from statistics import mean
import matplotlib.pyplot as plt
import numpy as np
from scipy import stats
def remove_outliers(data, threshold = 2):
z_scores = np.abs(stats.zscore(data))
filtered_data = data[(z_scores < threshold)]
return filtered_data
def calculate_most_probable_mean(data):
# Remove outliers using the Z-score method
filtered_data = remove_outliers(data)
# Calculate the mean of the filtered data
mean = np.mean(filtered_data)
return mean
dp_data = []
for i in range(0, 1001, 2):
file = open(f'./dp_data/{i}.txt', 'r')
lines = file.readlines()
data= [int(line[:-1]) for line in lines]
data = np.array(data)
mean = calculate_most_probable_mean(data)
dp_data.append(mean)
fd_data = []
for i in range(0, 1001, 2):
file = open(f'./fd_data/{i}.txt', 'r')
lines = file.readlines()
data= [int(line[:-1]) for line in lines]
data = np.array(data)
fd_data.append(calculate_most_probable_mean(data))
index = [i for i in range(0, 1001, 2)]
plt.plot(index, dp_data)
plt.plot(index, fd_data)
plt.show()