0
I have a Python code, where I have an array (g) of 10,000 elements. After performing a draw using Andom.Choice(g) that draws any of these 10000 elements. However, I would like my final value to be between a certain range, because eventually the draw ends up picking values out of the range.
First I put if and Else codition, but eventually it happens to draw values out of the range, because these coditions only prevent it from happening the first time. I thought about putting a while loop, but I can’t implement it. Below is part of the code
Basically, this is where I Gero my array with 10000 elements
mu = 0.7416
sigma = 0.0876
g = np.random.normal (mu, sigma, 10000)
Here is only the average value of the generated distribution, nothing that influences my doubt
def calculo_dist_internuclear():
media = stats.gmean(g, axis=0)
return media
print ('Distância internuclear mais provável:', calculo_dist_internuclear()
Here I draw the generated array
valor_escolhido = random.choice(g)
print ('O valor sorteado foi:', valor_escolhido)
if (0.5916 < valor_escolhido < 0.8916):
valor_escolhido_FC1 = valor_escolhido
print ("Sorteio de primeira:", valor_escolhido_FC1)
else:
valor_escolhido_FC2 = random.choice(g)
print ("Sorteio realizado novamente:", valor_escolhido_FC2)