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

Click For Summary
SUMMARY

The discussion focuses on generating random x-y coordinates within a 2x2 square centered at (0, 0) using the randn function, which produces normally distributed numbers. The requirement is to ensure that all generated points have a radial distance (r) of less than 1 from the origin. A suggested approach involves discarding points that fall outside the specified square, although this may compromise the normal distribution of the points. The challenge lies in balancing the need for a normal distribution with the spatial constraints of the square.

PREREQUISITES
  • Understanding of the randn function for generating normally distributed numbers
  • Basic knowledge of coordinate systems and radial distance calculations
  • Familiarity with programming concepts for implementing random number generation
  • Awareness of statistical distributions and their properties
NEXT STEPS
  • Research methods for generating random points within a circle using the Box-Muller transform
  • Explore techniques for transforming normally distributed points to fit within specific geometric constraints
  • Learn about rejection sampling as a method for generating points within defined boundaries
  • Investigate the implications of point distribution on statistical analysis and data representation
USEFUL FOR

Data scientists, programmers, and statisticians interested in random number generation, spatial data analysis, and the application of statistical distributions in programming.

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

  • · Replies 10 ·
Replies
10
Views
4K
  • · Replies 1 ·
Replies
1
Views
5K
  • · Replies 9 ·
Replies
9
Views
5K
  • · Replies 2 ·
Replies
2
Views
10K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 13 ·
Replies
13
Views
2K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 11 ·
Replies
11
Views
3K