mercredi 7 février 2018

Plot each iteration of for loop within if else statement in Python

I'm new to this asking question business so take it easy on me eh?

My goal is to plot each step of a for loop where I have nested an if else statement. I'm not sure where to begin in regards to how to plot each iteration? Any thoughts are greatly appreciated.

Code is here below....

for i in range(1,1001): #compute a random number between 0 and 1, following uniform distribution x=np.random.uniform(0,1,None)

if state==0: 
    #we are in state 0
    if x<pi11:
        state=0
        freq_state0=freq_state0+1

    else:
        state=1
        freq_state1=freq_state1+1

else: #we are in state 1
    if x<(1-pi22):
        state=0
        freq_state0=freq_state0+1

    else:
        state=1
        freq_state1=freq_state1+1

Aucun commentaire:

Enregistrer un commentaire