emms的最大似然估计与模型选择
exp-mixture-model的Python项目详细描述
exp_mixed_模型
指数混合模型的最大似然估计和模型选择(即指数分布混合)使用此代码时,请引用以下文件:
冈田真本,山下健二,直田。 事件间时间的长尾分布是指数分布的混合。 arxiv:19xx.xxxxx
安装
exp_mixture_model
托管在pypi上。因此,可以通过运行
pipinstallexp_mixture_model
如果要从源代码安装,请运行
gitclonehttps://github.com/naokimas/exp_mixture_model.git
然后,导航到克隆目录的顶层并运行
pythonsetup.pyinstall
您可以通过运行
pythonsetup.pytest
如果您使用anaconda,则可以通过运行
condainstall--filerequirements.txt
快速使用
运行
pythonemmfit.py-fsample.dat-k10
- “10”是组件的初始数目。
- “sample.dat”作为此包的一部分提供。我们通过运行
fromemmimportgenerate_emmx=generate_emm(1000,10)
若要在具有不同数量组件的EMM中选择最佳模型,请不要指定“k”,而是使用“-c”指定模型选择条件,如下所示。
pythonemmfit.py-fsample.dat-cDNML
- 可以指定“边际对数似然”、“联合对数似然”、“AIC”、“BIC”、“AIC-LVC”、“BIC-LVC”、“NML-LVC”或“DNML”作为“-c”的参数
- 默认值为“dnml”。
通过运行查看用法的详细信息
pythonemmfit.py--help
用法
通过运行使EMM适合数据
fromexp_mixture_modelimportEMMx=[1.5,2.3,...]# data can be either a list or numpy array## Alternatively, one can load data from a file using numpy as follows.## import numpy as np# x = np.loadtxt("sample.dat")#model=EMM()pi,mu=model.fit(x)# estimate the parametersmodel.print_result()# print 'k_final' (i.e., the estimated effective number of components) and the estimated parametersmodel.plot_survival_probability()# plot the survival probability (= cumulative complementary distribution function) for the estimated EMM and the given data 'x'.
根据模型选择标准,通过运行
fromexp_mixture_modelimportEMMsx=[1.5,2.3,...]emms=EMMs()emms.fit(x)# fit EMMs with different values of 'k', i.e., the number of components. The default uses 13 values of 'k'. This process is computationally heavy.best_model=emms.select('DNML')# select the best number of components under the 'DNML' criterion. One can specify either 'marginal_log_likelihood', 'joint_log_likelihood', 'AIC', 'BIC', 'AIC_LVC', 'BIC_LVC', 'NML_LVC', or 'DNML' as the argument of 'emms.select'.emms.print_result_table()# print the values of 'k_final', likelihoods, and 'DNML' for each 'k' valuebest_model.print_result()# print 'k_final' and the estimated parameter values of the selected EMM