How to distribute random points according to the Epanechnikov distribution values
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/168049/image.png)
Risposte (1)
Roger Stafford
il 23 Dic 2017
Modificato: Roger Stafford
il 23 Dic 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 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!