关于加快 SciPy 自定义分布采样和拟合的建议

Advice on Speeding up SciPy Custom Distribution Sampling & Fitting

我正在尝试使用 scipy 将自定义分布拟合到大型(~O(500,000) 次测量)数据集。我已经根据一些其他因素导出了一个理论上的 PDF,但是无论是手工还是使用符号积分软件,我都找不到 CDF 的确切形式。

目前,从我的自定义分布中简单地评估 1000 个随机样本是昂贵的,我认为这是由于需要反转未知的 CDF。如果我找不到 CDF 的显式形式并且它是逆的,我还能做些什么来加速这个分布的使用吗?

我已经使用 maple、matlab 和 Sympy 尝试确定 CDF,但 none 给出了结果。我还尝试对我的数据进行下采样,同时仍然保留尾部属性,但这仍然需要太多数据,以至于对分布做任何事情都很慢。

我的发行版是 SciPy 的 rv_continuous class 的子版 class。

感谢任何建议。

这听起来像是您想从 Kernel Density Estimation of the probability distribution. While Scipy does offer a Gaussian Kernel package, for that many measurements you would be much better off using sklearn's implementation. A good resource with code examples can be found on Jake VanderPlas's blog 中采样。