python - 如何将高斯函数分割为等体积部分

标签 python statistics signal-processing gaussian

我正在尝试使用 Python 将高斯形曲线分割为 K 个等体积段,以实现信号过滤目的。

我正在寻找伪代码、总体思路或执行它的库。 任何帮助将不胜感激。

谢谢!

例如下图中:K=6。卷 s1 = s2 = ... = s6:

enter image description here

最佳答案

您需要确定分布的百分位数。您可以使用此 scipy.stats.norm 类及其 .ppf() 方法。

import numpy as np
import scipy.stats as sps
import matplotlib.pyplot as plt

mu = 25
sigma = 4
splits = 8

# define the normal distribution and PDF
dist = sps.norm(loc=mu, scale=sigma)
x = np.linspace(dist.ppf(.001), dist.ppf(.999))
y = dist.pdf(x)

# calculate PPFs
step = 1 / splits
quantiles = np.arange(step, 1.0 - step / 2, step)
ppfs = dist.ppf(quantiles)  # boundaries

# plot results
fig, ax = plt.subplots(figsize=(10, 4))
ax.plot(x, y, color='k')
for i, ppf in enumerate(ppfs):
    ax.axvline(ppf, color=f'C{i}', label=f'{quantiles[i]:.3f}: {ppf:.1f}')
ax.legend()
plt.show()

enter image description here 这是基于this answer

关于python - 如何将高斯函数分割为等体积部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70607362/

相关文章:

python - 在python中以特定格式获取日期

python - 在 Windows 中读取 Ubuntu 机器上写入的 excel 文件时出错(使用 Pandas)

python - 使用 scipy.stats 使用自定义分布拟合数据

machine-learning - 可以使用经过普遍训练的深度学习分类器在子类中进行分类吗?

signal-processing - GNU radio DQPSK 误码率

python - 多项式NB错误: "Unknown Label Type"

java - 在 Python/Java 服务器/客户端之间发送对象

R - "CAPdiscrim"和 "lda"错误 "variable 1 appears to be constant within groups"

java - 分布式 "dumping"/"compressing"数据样本

signal-processing - Linux机器上最快的MFCC提取方法