random numer generation except inside of the circle in python


I want to generate 750 random number in 2D data x (0,1) and y (0,1)

X1 = np.random.random((750,2))

However, I want to make sure I don’t have any value in the circular region such as

enter image description here

I can remove the value, but I want to fix the number of the random number to be 750. What would be the best way to generate such list?


import random
points = []
radius = 1
index = 0
max_coord = 750
while index < num_points:
  if x**2 + y**2 > radius**2:
    points = points + [[x,y]]
    index = index + 1

Change max_coor to obtain bigger numbers. This only gives you 1500 points outside the circle of the given radius=1. Each coordinate varies between 0 and 750

Answered By – hjbello

Answer Checked By – Cary Denson (AngularFixing Admin)

Leave a Reply

Your email address will not be published.