SHARE
TWEET

Untitled

a guest Mar 20th, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. data = {{x1,y1},{x2,y2},...}
  2.      
  3. datadistr = SmoothKernelDistribution[data]
  4. PDF[datadistr, {x, y}]
  5.      
  6. (* Generate some bounded data *)
  7. data = RandomVariate[BinormalDistribution[{0, 0}, {1, 1}, 0.9], 5000];
  8. data = Select[data, #[[1]] > -1 && -1 < #[[2]] < 1 &];
  9.  
  10. (* Get nonparametric density estimate *)
  11. skd = SmoothKernelDistribution[data, 0.3, {"Bounded", {{-1, ∞}, {-1, 1}}, "Gaussian"}];
  12.  
  13. (* Show results *)
  14. Show[ListPlot[data, PlotRange -> {{-1.5, 3}, {-1.5, 1.5}}, Frame -> True],
  15.  ContourPlot[PDF[skd, {x, y}], {x, -1.5, 3}, {y, -1.5, 1.5},
  16.   ContourShading -> None, PlotPoints -> 100]]
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top