mardi 31 mars 2020

Do you know a way to change the loop for something more productive?

i'm looking to do that loop with the condition in a way that is simpler and more productive. Can anybody can think of a way to do it? Thank you in advance for your help!! :)

OptVariableControle =np.array([])    
    j = 1
    for i in range (0,27):
        if  i == 2 :
            j = j+1
        if  i == 5:
            j = j+1
        if  i == 8:
            j = j+1
        if  i == 11:
            j = j+1
        if  i == 14:
            j = j+1
        if  i == 17:
            j = j+1
        if  i == 20:
            j = j+1
        if  i == 23:
            j = j+1
        OptVariableControle =np.append(OptVariableControle, 
                        (optionsActualise[i] + betas["beta" + str(j)]* (optionsActualise[i]-esperences[i])))

Aucun commentaire:

Enregistrer un commentaire