-
Notifications
You must be signed in to change notification settings - Fork 1
/
simpleCubic.jseo
36 lines (33 loc) · 1.29 KB
/
simpleCubic.jseo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
{
/*Below are the two requried parameters*/
"func": function (xVector, P) {
return P[0] * Math.pow(xVector[0],3) + P[1];
},
"setInitial": function (x_mat, y_vec) {
// For other data, this must be made more intelligent
var A = ( y_vec[1] - y_vec[0] ) / (Math.pow(x_mat[1][0], 3) - Math.pow(x_mat[0][0], 3));
var B = y_vec[0] - A * Math.pow(x_mat[0][0], 3);
return [A, B];
},
/*Below is a functional optional parameter,
any number of the internal parameters may be left off*/
"func_fit_params": {
"maxItt": 1010, /*Default: 1000*/
"minPer": 0.9e-6, /*Default: 1e-6*/
"checkItt": 4, /*Default: 3*/
"converge": 1.21, /*Default: 1.2*/
"diverge": -0.51, /*Default: -0.5*/
"step": function (initParameters) {
var ret = [];
for (var i = 0; i < initParameters.length; i += 1) {
ret[i] = initParameters[i]/105; /*Default: x/100*/
}
return ret;
}
},
/*Below are completely optional, non functional parameters
any number may be added, these and all other parameters are
static.*/
"description": "For fitting two parameter Ax^3+B cubic function",
"stringified": "a * x ^ 3 + b"
}