Wolfram
Mathematica
8의 신기능: 비모수 분포, 파생 분포, 포뮬라 분포
◄
이전
|
다음
►
핵심 알고리즘
밀도 추정에서의 최적화
최소 자승 교차 타당 구간에 대한 풀이에
KernelMixtureDistribution
의 기호 처리 영향을 받게 됩니다. 이 방법은 추정 결과의 에러의 제곱에 대한 적분값을 최소화하는 구간을 선택하는 남겨진 교차 타당도를 이용합니다.
In[1]:=
X
d = BlockRandom[SeedRandom[12]; RandomVariate[NormalDistribution[], 25]]; Rk[h_, data_] := With[{n = Length[data]}, 1/(h Sqrt[\[Pi]]) (Exp[-((Subtract @@@ Subsets[data, {2}])^2/(4 h^2))].ConstantArray[1/n^2, Total[Range[1, n - 1]]] + 1/(2 n))] Ro[h_, data_] := Total[1/((Length[data] - 1) h Sqrt[2 \[Pi]]) Table[ Plus @@ Exp[-(data[[i]] - Delete[data, {i}])^2/(2 h^2)], {i, Length[data]}]] LSCV[h_, data_] := With[{n = Length[data]}, Rk[h, data] - 2/n Ro[h, data]] bw = h /. FindMinimum[LSCV[h, d], {h}][[2]];
In[2]:=
X
\[ScriptCapitalD] = KernelMixtureDistribution[d, bw];
In[3]:=
X
Show[Plot[LSCV[h, d], {h, 0.03, 2}, PlotLabel -> Text[Style[Row[{"h \[Rule] ", bw}], Bold, FontFamily -> "Verdana", FontSize -> 14]], Frame -> True, Axes -> None, Filling -> None, PlotStyle -> Thick, PlotRange -> {{0, 1.99}, {-.39, 0}}, ImageSize -> {570, 374}], Graphics[{Lighter[Blend[{Red, Orange}], 0.3], Dashed, Thick, Line[{{bw, -.385}, {bw, .005}}]}], Epilog -> Inset[Plot[PDF[\[ScriptCapitalD], x], {x, -3.5, 3}, Filling -> Axis, FillingStyle -> Lighter[Blend[{Red, Orange}], 0.4], Axes -> {True, False}, ImageSize -> 360], {1.3, -.24}]]
Out[3]=