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

Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
1 reply · 3K views
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.