运行此命令时:
query = Q()
for box_id, toy_color in [[10, 3], [4, 5], [1, 2]]:
query |= Q(Q(id=box_id) & Q(toys__colors=toy_color))
Box.objects.filter(query)
它应在直方图中生成Gamma分布的曲线。取而代之的是,它仅沿x轴绘制一条平线。
我在这里做什么错了?
答案 0 :(得分:3)
您对模型的系数不正确。速率参数应接近0.03。
x<-c(73,6,77,81,91,120,150,61,65,68,18,20,23,12,14,18,23,26,26,27, 2,3,3,40,41,41,6,10,11,12,37,38,38,6,73,6,51)
library(fitdistrplus)
model<-fitdist(x, "gamma")
print(model$estimate)
# shape rate
#1.1911710 0.0311047
a=model$estimate[1]
b=model$estimate[2]
h<-hist(x,breaks=c(0,20,40,60,80,100,120,160),probability = T)
curve(dgamma(x,a,b),from=0,to=160,col="red",lwd=2,add=T)
答案 1 :(得分:1)
您的x向量似乎不包含带有这些参数(a,b)的伽马分布的实现。试试这个:
a<-1.286486
b<-30.59584
num<-rgamma(1000,a,b)
hist(num,nclass = 100,freq=F)
curve(dgamma(x,a,b),col="red",lwd=2,add=T)