MATLAB: How to generate clustered or linearly distriuted random points in a plane

random pointsstatisticsStatistics and Machine Learning Toolbox

Hi, I need to generate a set of random points (say 100 points) in the cartesian plane. The x and y values can range from 0 to 1, but there should be more points towards the bottom of the plane…. say maybe 40 or 45 of the points must have a y value less than 0.3… Is it possible?
Lekshmi
Edit : Is it possible to just distribute the points linearly along the y direction? That is, the points must be densely placed nearer zero, and get sparser as we move to 1. The whole thing must be more or less random with regard to placement of the points, but biased towards the bottom…. and the distribution must be linear. My knowledge of statistics is pretty bad.. so i dont know how exactly to put it.

Best Answer

  • Do you have the Statistics Toolbox?
    If so, how about using a Beta random variable for your Y and a uniform random variable for X -- you did not state that the X should be clustered in any portion of the plane.
    The Beta distributions has two parameters, A and B, the expected value is A/(A+B)
    Below I'll use a Beta RV with an expected value of 1/3.
    y = betarnd(2,4,100,1);
    x = rand(100,1);
    XY = [x y];
    Visualize
    plot(XY(:,1),XY(:,2),'*')
    If you execute the following, you'll see by the Beta(2,4) PDF why a majority of the points will be concentrated closer to 0.3 than 1.
    x = 0:0.01:1;
    y = betapdf(x,2,4);
    plot(x,y)
    Of course you can play with the parameters to obtain the Y distribution you want.
    y = betapdf(x,1,5);
    plot(x,y)