Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168742
Image: ubuntu2004
# Madison Schaeffer & Evan Raskin import numpy as np x = np.array([0.,1.,2.,3.,4.]) S = np.array([500.,400.,200.,50.,0.]) b = np.array([0.,2.,3.,1.,0.]) def lx(S): return S/S[0] R0 = np.sum(lx(S)*b) G = np.sum(x*lx(S)*b)/R0 print lx(S) print R0 print G sign = ['+'] RVALUE = log(R0)/G print RVALUE refined_r = [RVALUE] def refine(): global sign global refined_r if abs(1 - np.sum(lx(S)*b*exp(-refined_r[-1]*x))) > .001: if (1 - np.sum(lx(S)*b*exp(-refined_r[-1]*x))) > 0: sign.append('-') if sign[-2] != sign[-1]: binary() else: decrease_me() else: sign.append('+') if sign[-2] != sign[-1]: binary() else: increase_me() else: print refined_r[-1], 'LIZARD!' def decrease_me(): refined_r.append(refined_r[-1]*.9) refine() def increase_me(): refined_r.append(refined_r[-1]*1.1) refine() def binary(): refined_r.append((refined_r[-1] + refined_r[-2])/2) refine() refine()
[ 1. 0.8 0.4 0.1 0. ] 2.9 1.48275862069 0.7180607296 0.776744726549 LIZARD!
2