# python - 将数据拟合到分布？

``````
1 10
2 5
3 20
...
...

``````

``````
x = rnorm( n = 100, mean = 0, sd = 1 )

``````

``````
library(MASS)
params = fitdistr( x,"normal" )
print( params )

``````

``````
mean sd
-0.17922360 1.01636446
( 0.10163645) ( 0.07186782)

``````

``````
print( params\$loglik )
[1] -139.5772

``````

``````
x = x[ x >= 0 ]

distributions = c("normal","exponential")

for ( dist in distributions ) {
print( paste("fitting parameters for", dist ) )
params = fitdistr( x, dist )
print( params )
print( summary( params ) )
print( params\$loglik )
}

``````

``````
[1]"fitting parameters for normal"
mean sd
0.72021836 0.54079027
(0.07647929) (0.05407903)
Length Class Mode
estimate 2 -none- numeric
sd 2 -none- numeric
n 1 -none- numeric
loglik 1 -none- numeric
[1] -40.21074
[1]"fitting parameters for exponential"
rate
1.388468
(0.196359)
Length Class Mode
estimate 1 -none- numeric
sd 1 -none- numeric
n 1 -none- numeric
loglik 1 -none- numeric
[1] -33.58996

``````

• 未定义
• 未定义
• 未定义

。G 和A 。 斯图尔特，高级统计理论，vol 。 1查尔斯·格里芬, 1963是我发现的最完整的参考,高达整个页面的主题,其他大多数文献最多有一个句子或上市方面的扩张的时刻,而不是累积量有点用处。 幸运的是找到一份副本，但是我不得不向我的大学管理员发送一个旅行到存档。 但这是很久以前的了，所以也许互联网今天会更有帮助。

• 来自具有未知分布的随机进程的数据，
• 对基础进程的约束

``````
library("plyr")
library("e1071")

realData <- rnorm(1000) #Real data is normally distributed

distToTest <- list(qnorm ="qnorm", lognormal ="qlnorm", qexp ="qexp")

#function to test real data against list of distributions 上面. Output is a jpeg for each distribution.
testDist <- function(x, data){
jpeg(paste(x,".jpeg", sep =""))
probplot(data, qdist = x)
dev.off()
}

l_ply(distToTest, function(x) testDist(x, realData))

``````