在Mathematica中将插值函数转换为PDF

5

我想要使用函数插值作为PDF,并且能够使用Mean,Probability,CDF等工具。我已经完成了以下步骤:

 f = Interpolation[data];
 dist = ProbabilityDistribution[f[x], {x,0,1000}];

举个例子,当我尝试执行以下操作:

Mean[dist] //N

它只是返回输入的内容。其他函数也是如此。

3个回答

2
您可以使用离散分布:
data = {1, 2, 1, 3, 4};
data = data/Total@data;
f = Interpolation[data];
dist = ProbabilityDistribution[f[x], {x, 1, 5, 1}];
Mean[dist] // N

1

你也可以尝试使用SmoothKernelDistrubution。

d = SmoothKernelDistribution[data];

cdf=CDF[d]

Plot[cdf[x], {x, -1, 1}]

Quantile[d, 0.95]

Moment[d, 2]

1
你可以使用 EmpiricalDistribution
f = EmpiricalDistribution[data]

Mean[f]
(* 1/5 *)

Expectation[x^3, x \[Distributed] f]
(* 101/6655 *)

Moment[f, 2]
(* 31/605 *)

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接