Guest User

Untitled

a guest
Nov 24th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. SeedRandom[1];
  2.  
  3. nPoints = 100000;
  4.  
  5. xmin = 0; ymin = 15;
  6. xmax = 45; ymax = 32;
  7.  
  8. points = Transpose[{RandomReal[{xmin, xmax}, nPoints], RandomReal[{ymin, ymax}, nPoints]}];
  9.  
  10. Do[
  11. Do[
  12. number[[i, j]] =
  13. Length@Nearest[points, {xmin + (i - 1)*dx + dx/2, ymin + (j - 1)*dy + dy/2},
  14. {All, radius}];
  15. , {j, 1, Round@((ymax - ymin)/dy), 1}
  16. ];
  17. , {i, 1, Round@((xmax - xmin)/dx), 1}
  18. ]; // AbsoluteTiming
  19.  
  20. {35.9987, Null}
  21.  
  22. ListDensityPlot[Transpose@number, ColorFunction -> "Rainbow", AspectRatio -> Automatic,
  23. PlotRangePadding -> None, Frame -> True, InterpolationOrder -> 0]
Add Comment
Please, Sign In to add comment