2

出于可重复性的原因,我在这里分享几个数据集。数据集具有以下格式。

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()

这给出了以下图。

在此处输入图像描述 在此处输入图像描述 在此处输入图像描述 在此处输入图像描述

从图中我们可以看出

  • Data-G,不管数值quotient_times是多少,商总是>=0.9
  • quotient_times当小于 3时, Data-V的商为 0.8,如果大于 3,则商保持为 0.5 quotient_times

  • quotient无论值是多少, Data-C的常数都是 0.7 quotient_times

  • quotient无论值是多少,Data-R的常数都是 0.5quotient_times

基于此要求,我们如何绘制高斯混合模型?任何帮助,将不胜感激。

4

0 回答 0