 |
Defining a non-parametric function with 2 variables
Source code name: "func_nonparametric2.py"
Programming language: Python
Topic: Function/Non-parametric
DMelt Version 1. Last modified: 12/11/2015. License: Pro
https://datamelt.org/code/cache/func_nonparametric2_1121.py
To run this script using the DMelt IDE,
copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.
from java.lang import Math
from jhplot import *
class MyFunc(FNon):
def value(self, x):
y=x[0]*x[0]*Math.sqrt(x[0])*self.p[0]+self.p[1]
if (x[0]<4): y=0
return y
c1 = HPlot() # plot data and the fit function
c1.visible()
c1.setAutoRange()
pl = MyFunc("test",1,2)
print "f(2)= ",pl.value([2])
print pl.numberOfParameters()
print pl.dimension()
print pl.parameterNames().tolist()
pl.setParameter("par0",100)
pl.setParameter("par1",20)
print pl.parameters()
f1=F1D(pl,0,10) # convert to plottable function
c1.draw(f1)
You see the box below because you did not login.