bayesian_blocks#

astropy.stats.bayesian_blocks(t, x=None, sigma=None, fitness='events', **kwargs)[源代码]#

使用斯卡格尔的贝叶斯数据块计算数据的最优分割。

这是Scargle2013中描述的贝叶斯块算法的灵活实现 [1].

参数:
t : array_likeNumpy:ARRAY_LIKE

数据时间(一维,长度N)

x : array_like ,可选NumPy:ARRAY_LIKE,可选

数据值

sigma : array_likefloat ,可选NumPy:ARRAY_LIKE或PYTHON:FLOAT,可选

数据错误

fitness : strobjectPYTHON:字符串或对象

要用于模型的适应度函数。如果是字符串,则支持以下选项:

  • '事件' : binned or unbinned event data. Arguments are gamma, which gives the slope of the prior on the number of bins, or ncp_prior, which is \(-\ln({{\tt gamma}})\) .

  • 'regular_events' : non-overlapping events measured at multiples of a fundamental tick rate, dt, which must be specified as an additional argument. Extra arguments are p0, which gives the false alarm probability to compute the prior, or gamma, which gives the slope of the prior on the number of bins, or ncp_prior, which is \(-\ln({{\tt gamma}})\) .

  • “措施” : fitness for a measured sequence with Gaussian errors. Extra arguments are p0, which gives the false alarm probability to compute the prior, or gamma, which gives the slope of the prior on the number of bins, or ncp_prior, which is \(-\ln({{\tt gamma}})\) .

在所有三种情况下,如果 p0gammancp_prior 被选中, ncp_prior 优先于 gamma 哪个优先 p0 .

或者,适应度参数可以是 FitnessFunc 或其子类。

**kwargs

任何其他关键字参数都将传递给指定的 FitnessFunc 派生类。

返回:
edges : ndarray恩达雷

包含定义N个箱子的(N+1)边的数组

参见

astropy.stats.histogram

使用贝叶斯块计算直方图

工具书类

[1]

斯卡格尔,J等人。(2013)https://ui.adsabs.harvard.edu/abs/2013ApJ...764..167S

[2]

贝尔曼,R.E.,德雷福斯,S.E.,1962。应用动态规划。普林斯顿大学出版社,普林斯顿。Https://press.princeton.edu/books/hardcover/9780691651873/applied-dynamic-programming

[3]

贝尔曼,R.,罗斯,R.,1969。用分段直线进行曲线拟合。J·阿梅尔。统计学家。阿索克。64,1079-1084。Https://www.tandfonline.com/doi/abs/10.1080/01621459.1969.10501038

实例

事件数据:

>>> t = np.random.normal(size=100)
>>> edges = bayesian_blocks(t, fitness='events', p0=0.01)

具有重复的事件数据:

>>> t = np.random.normal(size=100)
>>> t[80:] = t[:20]
>>> edges = bayesian_blocks(t, fitness='events', p0=0.01)

常规事件数据:

>>> dt = 0.05
>>> t = dt * np.arange(1000)
>>> x = np.zeros(len(t))
>>> x[np.random.randint(0, len(t), len(t) // 10)] = 1
>>> edges = bayesian_blocks(t, x, fitness='regular_events', dt=dt)

有误差的测点数据:

>>> t = 100 * np.random.random(100)
>>> x = np.exp(-0.5 * (t - 50) ** 2)
>>> sigma = 0.1
>>> x_obs = np.random.normal(x, sigma)
>>> edges = bayesian_blocks(t, x_obs, sigma, fitness='measures')