Create Random Points in Elliptical Belt
Show older comments
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!
Accepted Answer
More Answers (1)
Bruno Luong
on 23 Nov 2020
Edited: Bruno Luong
on 23 Nov 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 Comment
Gaelle Rabarison
on 23 Nov 2020
Categories
Find more on Least Squares in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!