# Использование непараметрических моделей данных произвольной размерности

Двумерная оценка плотности распределения вулканических кратеров в Уганде.
 In[1]:= Xdat = ExampleData[{"Statistics", "UgandaVolcanoes"}]; poly = ExampleData[{"Statistics", "WesternUgandaBorder"}];
 In[2]:= X\[ScriptCapitalD] = SmoothKernelDistribution[dat, "SheatherJones"];
 In[3]:= XinPolyQ = Compile[{{polygon, _Real, 2}, {x, _Real}, {y, _Real}}, Block[{polySides = Length[polygon], X = polygon[[All, 1]], Y = polygon[[All, 2]], Xi, Yi, Yip1, wn = 0, i = 1}, While[i < polySides, Yi = Y[[i]]; Yip1 = Y[[i + 1]]; If[Yi <= y, If[Yip1 > y, Xi = X[[i]]; If[(X[[i + 1]] - Xi) (y - Yi) - (x - Xi) (Yip1 - Yi) > 0, wn++;];];, If[Yip1 <= y, Xi = X[[i]]; If[(X[[i + 1]] - Xi) (y - Yi) - (x - Xi) (Yip1 - Yi) < 0, wn--;];];]; i++]; ! wn == 0]]; dens = ContourPlot[ Evaluate@PDF[\[ScriptCapitalD], {x, y}], {x, 0, 3000}, {y, 550, 4500}, PlotRange -> All, PlotPoints -> 50, Contours -> 15, RegionFunction -> (inPolyQ[poly, #1, #2] &), ColorFunction -> "TemperatureMap"];
 In[4]:= XShow[dens, ListLinePlot[poly, PlotStyle -> Thick], ListPlot[dat, PlotMarkers -> {Automatic, 8}, PlotStyle -> Black], ImageSize -> {381, 373}, GridLines -> Automatic]
 Out[4]=