How to distribute random points according to the Epanechnikov distribution values
6 views (last 30 days)
Show older comments
I want to get random points according to local maxima of the Epanechnikov distribution, such that the density of points is higher at the local maxima and the density of the points decreases in the minimum value.
Answers (1)
Roger Stafford
on 23 Dec 2017
Edited: Roger Stafford
on 23 Dec 2017
(Correction: I have eliminated the 1) version of the preceding answer, since it was incorrect.)
I interpret your 2D Epanechnikov distribution for random points in the following way. Both x and y coordinates of the points have independent Epanechnikov distributions with respect to a center (x0,y0). The points are restricted to a square.
x0 = 4; y0 = 6; % <-- Choose center of square
L = 14; % <-- Choose length of square sides
n = 8192; % <-- Choose number of points
x = x0+(sin(asin(2*rand(1,n)-1)/3))*L;
y = y0+(sin(asin(2*rand(1,n)-1)/3))*L;
X = x0+[-1,1,1,-1,-1]*L/2;
Y = y0+[-1,-1,1,1,-1]*L/2;
plot(X,Y,'r-',x,y,'y.')
axis equal
See https://www.mathworks.com/matlabcentral/answers/374276 for remarks about the method used to generate the Epanechnikov distribution.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!