Description Usage Arguments Examples
The function, fit_2D
, takes four arguments, func
, dat
, it
, op_v
and fits the 2D model described by the argument func
into the data described by the argument dat
. The parameter it
describes the number of iterations that the code generates before it decides to declare that the starting/intial values of the vector to be iterated, op_v
, is a bad starting point to search for a local minima within the given number of iterations, it
. In such cases the message solution did not converge
will be displayed. op_v
is a vector comprising the initial values/guess point from where the vector will iterate itself to look for a local minima. It must however be remembered that the function, fit_2D
, does not have pre-defined default values attached to its arguments and also that the function does not
under present circumstances support optimization algorithms with constraints
defined on them. This however is a work in progress and will be taken care of in future contexts.
1 | fit_2D(func, dat, it, op_v)
|
func |
The argument |
dat |
The argument |
it |
|
op_v |
1 2 3 4 5 6 7 8 9 10 11 12 | library(DataAnalyze1.0)
x<-seq(-10,10, by=0.02)
g<-function(v){
y<-v[1]*exp(-1*(((x-v[2])/(v[3]))^2))+2*v[1]*exp(-1*(((x-v[4])/(v[5]))^2))
return(y)
}
y<-3*exp(-1*(((x-4)/(5))^2))+6*exp(-1*(((x-4.5)/(4))^2))
y_d<-y+runif(length(x))
plot(x,y_d)
m<-matrix(c(y_d,x), byrow = T, nrow = 2)
v<-c(2.2,3.5,4.7,4.8,5)
fit_2D(func=g, dat=m, op_v = v, it=20000)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.