如何适应Python中的beta版本?

时间:2019-03-09 16:12:39

标签: python python-3.x numpy scipy statistics

我正在使用一个简单的数据集,出于可重复性的原因,我正在共享它here

为了使我清楚自己在做什么-从第2列开始,我正在读取当前行并将其与上一行的值进行比较。如果更大,我会继续比较。如果当前值小于上一行的值,我想将当前值(较小)除以上一个值(较大)。因此,以下代码:

import numpy as np
import scipy.stats
import matplotlib.pyplot as plt
import seaborn as sns

protocols = {}

types = {"data_v": "data_v.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()
    diff=quotient_times
    plt.plot(diff,beta_value, ".", label=protname, color="blue")
    plt.ylim(0, 1.0001)
    plt.title(protname)
    plt.xlabel("quotient_times")
    plt.ylabel("quotient")
    plt.legend()
    plt.show()
    sns.distplot(quotient, hist=False, label=protname)

这给出了以下图表。

enter image description here

enter image description here

从图中可以看到

    quotient_times小于3时,
  • Data-V 的商为0.8,如果quotient_times为0,则商保持0.5。 大于3。

基于此,当beta小于3且大于3时,如何将数据拟合为类似quetient_times的分布?直观地,当quetient_times小于3时,分布峰将集中在0.8左右。当quetient_times在3或3.05左右时,峰值将在0.8到0.5之间(50%,50%)。但是,当quetient_times大于3时,峰值将仅在0.5左右居中。我们如何在Python中做到这一点?

0 个答案:

没有答案