Hi I would like to generate two random numbers so that the sum of their squares is equal to 1.
I have written this code. The sum of their square may not be perfectly equal to 1 but it should be near like 0.999. I also used if(math.isclose(abs(gene_value_1)**2 + abs(gene_value_2)**2, 1)) but it doesn't work.
gene_value_1 = random.uniform(0,1)
gene_value_2 = random.uniform(0,1)
if(abs(gene_value_1)**2 + abs(gene_value_2)**2) == 1:
print(added)
I want to generate two random numbers where the sum of their squares is nearly equal to 1.
Aucun commentaire:
Enregistrer un commentaire