This concentration of points will be expected from how you build points. Your points are evenly distributed along the X axis. At the extreme points of the triangle, there are approximately the same number of points present in the center of the triangle, but they are distributed along a much smaller area.
The first and best approach I can think of: brute force. Distribute the points equally around the larger region, and then delete those that are outside the region of interest to you.
N = 1000; points = zeros(N,2); n = 0; while (n < N) n = n + 1; x_i = 20*rand-10; % generate a number between -10 and 10 y_i = 10*rand; % generate a number between 0 and 10 if (y_i > 10 - abs(x_i)) % if the points are outside the triangle n = n - 1; % decrease the counter to try to generate one more point else % if the point is inside the triangle points(n,:) = [x_i y_i]; % add it to a list of points end end % plot the points generated plot(points(:,1), points(:,2), '.'); title ('1000 points randomly distributed inside a triangle');
The result of the code I posted: 
one important expression about rejection : random distribution does not mean "evenly" distributed! If you randomly generate data from a uniform distribution, this does not mean that it will be "evenly distributed" along the triangle. In fact, you will see some clusters of points.
source share