2

標準以外の分布関数の場合、scipy.statsでkstestを使用できますか(学生tのDOFを変更するか、Cauchyのガンマを変更しますか?)私の最終的な目標は、私のディストリビューションフィットのための最大p値と対応するパラメータを見つけることですが、それは問題ではありません。KSテストのための非標準分布変数?

EDIT:

scipy.statのコーシーPDFがある:それは位置パラメータのために、ガンマのためx_0 = 0を意味

cauchy.pdf(x) = 1/(pi * (1 + x**2)) 

Y = 1私は実際に必要とします。それはこのように見える

cauchy.pdf(x, x_0, Y) = Y**2/[(Y * pi) * ((x - x_0)**2 + Y**2)] 

Q1)は、パラメータを変更するためのオプションを持っていると思われるので、生徒tは、少なくとも、おそらく

stuff = [] 
for dof in xrange(0,100): 
    d, p, dof = scipy.stats.kstest(data, "t", args = (dof,)) 
    stuff.append(np.hstack((d, p, dof))) 

のような方法で使用することができるだろうか?

Q2)正規分布完全方程式(シグマを変更する必要があります)とCauchy(上記のようにガンマを変更する必要がある)が必要な場合はどうしますか? 編集:非標準分布のためにscipy.statsを検索する代わりに、実際にp値を見つけるkstestに書き込む関数を供給することは可能ですか?

おかげで親切に

+0

それは私に聞こえますあなたはいくつかのデータを与えられた分布のパラメータを推定しようとしていますか? [対応する配布](http://docs.scipy.org/doc/scipy-0.14.0/reference/stats.html#continuous-distributions)には '.fit'メソッドを使用するべきです。 –

+0

@ juanpa.arrivillaga Dang ..はい私は分布の各パラメータに対して個々のKSテストを行う必要があり、上記のパラメータ例を考慮していないそれらの対応するディストリビューションのために '.fit'メソッドを使うことはできません。 Cauchyの場合)は、標準の式であり、これらのパラメータを変更する機会を単純化しているためです。ビジュアルの編集を追加しましょう。 – layces

+1

@いいえ、彼らは持っていません。例えば、 'norm'分布の場合、sigmaは' scale'パラメータに対応します。 muは 'loc'に対応します。同様に、Cauchyの場合、ガンマは 'scale'であり、x0は' loc'です。 –

答えて

1

あなたが本当にやりたいことは、このようにKT-テストをestimation.Usingパラメータは、それがために何を意味するか、実際にされていないようです。 corresponding distributionには.fitメソッドを使用する必要があります。今

>>> import numpy as np, scipy.stats as stats 
>>> arr = stats.norm.rvs(loc=10, scale=3, size=10) # generate 10 random samples from a normal distribution 
>>> arr 
array([ 11.54239861, 15.76348509, 12.65427353, 13.32551871, 
     10.5756376 , 7.98128118, 14.39058752, 15.08548683, 
     9.21976924, 13.1020294 ]) 
>>> stats.norm.fit(arr) 
(12.364046769964004, 2.3998164726918607) 
>>> stats.cauchy.fit(arr) 
(12.921113834451496, 1.5012714431045815) 

はすぐにドキュメントをチェックする:

>>> help(cauchy.fit) 

Help on method fit in module scipy.stats._distn_infrastructure: 

fit(data, *args, **kwds) method of scipy.stats._continuous_distns.cauchy_gen instance 
    Return MLEs for shape, location, and scale parameters from data. 

    MLE stands for Maximum Likelihood Estimate. Starting estimates for 
    the fit are given by input arguments; for any arguments not provided 
    with starting estimates, ``self._fitstart(data)`` is called to generate 
    such. 

    One can hold some parameters fixed to specific values by passing in 
    keyword arguments ``f0``, ``f1``, ..., ``fn`` (for shape parameters) 
    and ``floc`` and ``fscale`` (for location and scale parameters, 
    respectively). 

... 

Returns 
------- 
shape, loc, scale : tuple of floats 
    MLEs for any shape statistics, followed by those for location and 
    scale. 

Notes 
----- 
This fit is computed by maximizing a log-likelihood function, with 
penalty applied for samples outside of range of the distribution. The 
returned answer is not guaranteed to be the globally optimal MLE, it 
may only be locally optimal, or the optimization may fail altogether. 

そうに、あなたは簡単に行うことができ、のは、私は一定のこれらのパラメータのいずれかを保持したいとしましょう:

​​
+0

@laycesさんが回答を追加しました... –

関連する問題