Changeset 86
- Timestamp:
- 01/29/09 17:41:38 (7 years ago)
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/example_getCost.py
r79 r86 28 28 fwd = ForwardPolyFactory(params) 29 29 x = (array([range(101)])-50.)[0] 30 return fwd(x)30 return x,fwd(x) 31 31 32 32 … … 49 49 50 50 def plot_sol(params,linestyle='b-'): 51 x = (array([range(101)])-50.)[0]52 51 d = data(params) 53 pylab.plot( x,d,'%s'%linestyle,linewidth=2.0)52 pylab.plot(d[0],d[1],'%s'%linestyle,linewidth=2.0) 54 53 pylab.axis(plotview) 55 54 return 56 55 56 from numpy import sum as numpysum 57 def cost_function(params): 58 x = data(params)[1] - datapts 59 return numpysum(real((conjugate(x)*x))) 60 57 61 58 62 if __name__ == '__main__': 59 x = (array([range(101)])-50.)[0]60 63 plotview = [-60,60, 0,2500] 61 64 target = [1., 2., 1.] 62 datapts = data(target)65 x,datapts = data(target) 63 66 67 #myCost = cost_function 64 68 F = CostFactory() 65 69 F.addModel(ForwardPolyFactory,'poly',3)
Note: See TracChangeset
for help on using the changeset viewer.