出于可再现性的原因,我将共享少数数据集here。数据集的格式如下。你知道吗
0.080505471,10
0.080709071,20
0.080835753,30
0.081004589,40
0.081009152,30
0.181258811,41
0.181674244,40
从第2列中,我读取当前行并将其与前一行的值进行比较。如果更大,我会继续比较。如果当前值小于前一行的值,我想用当前值(较小)除以前一行的值(较大)。因此,以下代码:
import numpy as np
import scipy.stats
import matplotlib.pyplot as plt
import seaborn as sns
protocols = {}
types = {"data_g": "data_g.csv", "data_v": "data_v.csv", "data_c": "data_c.csv", "data_c": "data_c.csv"}
for protname, fname in types.items():
col_time,col_window = np.loadtxt(fname,delimiter=',').T
trailing_window = col_window[:-1] # "past" values at a given index
leading_window = col_window[1:] # "current values at a given index
decreasing_inds = np.where(leading_window < trailing_window)[0]
quotient = leading_window[decreasing_inds]/trailing_window[decreasing_inds]
quotient_times = col_time[decreasing_inds]
protocols[protname] = {
"col_time": col_time,
"col_window": col_window,
"quotient_times": quotient_times,
"quotient": quotient,
}
plt.figure(); plt.clf()
plt.plot(quotient_times, quotient, ".", label=protname, color="blue")
plt.ylim(0, 1.0001)
plt.title(protname)
plt.xlabel("quotient_times")
plt.ylabel("quotient")
plt.legend()
plt.show()
这将给出以下曲线图。你知道吗
我们可以从图中看到
quotient_times
的值是多少,商总是>;=0.9当quotient_times
小于3时,Data-V的商为0.8,而当quotient_times
小于3时,商仍为0.5
大于3。
无论quotient_times
的值是多少,Data-C的quotient
常数都是0.7。
无论quotient_times
基于这一要求,我们如何绘制一个高斯混合模型?任何帮助都将不胜感激。你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐