[Tutor] recursion sort of

Isaac Hall hall@ouhep1.nhn.ou.edu
Fri May 30 17:46:22 2003


One suggestion I might make...If I were doing this, instead of copying the 
results into an excel spreadsheet/graph, I would use one of pythons 
graphical interfaces to create the plot.  it id possible to do 
this with Tkinter, which ships with python, and there are also some other 
packages which are available on the net that make plotting even easier....
Just a thought...

Ike

On Fri, 30 May 2003, Jennifer Cianciolo wrote:


> > [My apologies for posting so much on this; it's an interesting
> problem!]
> 
> 
> that's ok with me!! :)
> 
> it's going to take me a while to decipher your suggestions, but I do
> understand the problem you pointed out with time.  
> 
> If you don't mind my sticking with what I had before for another
> moment, this is what I did before I got your message, because I
> realized (duh) that I am not interested in nt (the TOTAL of n1 + n2)
> I'm interested in the dynamics of n1 and n2 (we can imagine they're
> two different clones), specifially what will make them oscillate
> WITHIN the population (nt can stay constant all the time for all I
> care)
> 
> this is the little change
> 
> def run(n1, n2):
>      cycle = 1
>      while 1:
>          print n1  #change here
>          print n2  #change here
>          if n1>=800:
>              w1=0.1
>              nnew1=n1*2*w1
>          elif n1<=799:
>              w1=1.5
>              nnew1=n1*2*w1
>          if n2>=800:
>              w2=0.3
>              nnew2=n2*2*w2
>          elif n2<=799:
>              w2=1.1
>              nnew2=n2*2*w2
>          n1=int(n1*2*w1)    
>          n2=int(n2*2*w2)  
>          n1=n1+nnew1    #added (I think)
>          n2=n2+nnew2    #added     
>          cycle +=1   
> 
> if there are typos... believe it or not I'm manually copying these in.
>  One computer with internet... one with python... 
> don't ask.
> 
> but what this does is make n1 wave up and down and n2 wave up and down
> (like a sin curve, but I don't want to make it happen by asking to
> make a sin curve!)
> It's terribly hard to copy and paste the output of this though to
> graph in excel...
> 
> 
> I'll see what I can figure out about your suggustions
> thanks again!
> 
> Jen
>