Create Random Points in Elliptical Belt
Mostrar comentarios más antiguos
Hi,
I need to generate uniformly distributed points inside an elliptical belt.
I know how to randomly generate uniform points inside an ellipse, but I need uniform points between two ellipses of different sizes, both centred at the origin.
Thanks!
Respuesta aceptada
Más respuestas (1)
Bruno Luong
el 23 de Nov. de 2020
Editada: Bruno Luong
el 23 de Nov. de 2020
If the two ellipse has the same aspect ratio and aligned then this is the method without rejection.
n=1e4;
ax=3;
ay=1;
rint=1;
rext=2;
% "Straight" ellipse bell
% B = { (x,y) in R^2 st
% (x/axext)+^2 + (y/ayext)+^2 < 1 &
% (x/axint)+^2 + (y/ayint)+^2 > 1
% ellipses have the same aspect
% axint = ax*rint; ayint = ay*rint;
% axext = ax*rext; ayext = ay*rext;
% generate n points in B
xy=randn(2,n);
rxy=sqrt(sum(xy.^2,1));
r=rint^2+rand(1,size(xy,2))*(rext^2-rint^2);
xy=xy.*(r.^(1/2)./rxy);
xy=[ax;ay].*xy;
x=xy(1,:);
y=xy(2,:);
plot(x,y,'.')
axis equal

And it works just fine on thin-bell (rext=1.05)

or supper thin rext=1.001

1 comentario
Gaelle Rabarison
el 23 de Nov. de 2020
Categorías
Más información sobre Least Squares en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
