MATLAB Generating Random x-y Coordinates within a 2x2 Square Using randn Function

AI Thread Summary
The discussion centers on using the randn function to generate normally distributed random x and y values constrained within a 2 x 2 square centered at (0, 0). The user seeks assistance in ensuring that all generated points fall within this specified area while adhering to the requirement of using randn. A key point raised is the potential issue of maintaining a normal distribution if points outside the square are discarded, as this would alter the distribution of the remaining points. The conversation highlights the challenge of balancing the constraints of the random number generation with the desired statistical properties.
strokebow
Messages
122
Reaction score
0
Okay... I am using the randn function for a sequence of normally distributed numbers.
I am writing a program whereby I need to use this randn to give me random x and y values whose position r is less than 1

i.e. that is to say that all points fall within a 2 x 2 square centred at (0, 0).
And I MUST use randn

Can anyone help me achieve this.

thanks
 
Physics news on Phys.org
Do you need the points to have any particular distribution (normal, uniform, etc.)? You could just discard any generated points that fall outside the 2 x 2 square, but then the points will not have a normal distribution.
 

Similar threads

Back
Top