简体   繁体   English

没有SciPy的Python中的分布拟合

[英]Distribution fitting in Python without SciPy

I am writing a python script that needs to make a distribution fit against some generated data. 我正在编写一个Python脚本,该脚本需要使分布适合某些生成的数据。

I found that this is possible using SciPy, or other packages having SciPy as dependency; 我发现使用SciPy或其他具有SciPy作为依赖项的程序包是可行的。 however, due to administrative constraints, I am unable to install SciPy's dependencies (such as Blas) on the machine where the script will run. 但是,由于管理上的限制,我无法在运行脚本的计算机上安装SciPy的依赖项(例如Blas)。

Is there a way to perform distribution fitting in Python without using SciPy or packages depending on it? 有没有一种方法可以在Python中执行分布拟合而无需使用SciPy或依赖于它的软件包?

EDIT : as asked in a comment, what I want to do is perform an Anderson-Darling test for normality. 编辑 :如评论中所问,我要执行的操作是执行Anderson-Darling测试的正态性。

The alternatives I found so far (but had to disregard): 我到目前为止发现的替代方法(但必须忽略):

  1. statsmodel : has SciPy as dependency statsmodel :具有SciPy作为依赖项
  2. R and Matlab python apis: need setup of external software, same problem for me as SciPy R和Matlab python API:需要安装外部软件,对我来说,与SciPy同样的问题

Fitting the normal distribution only requires calculating mean and standard deviation. 拟合正态分布只需要计算平均值和标准偏差。

The Anderson-Darling test only requires numpy or alternatively could be rewritten using list comprehension. Anderson-Darling测试仅需要numpy,或者可以使用列表理解来重写。 The critical values for the AD-test are tabulated or based on a simple approximation formula. 将AD测试的临界值制成表格或基于简单的近似公式。 It does not use any difficult parts of scipy like optimize or special. 它不使用任何困难的部分,例如优化或特殊。

So, I think it should not be too difficult to translate either the scipy.stats or the statsmodels version to using pure Python or only with numpy as dependency. 因此,我认为将scipy.stats或statsmodels版本转换为使用纯Python或仅将numpy作为依赖项应该不难。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM