Skip to main content
POST
/
quantlib
/
numerical
/
least-squares
/
fit
Nonlinear Least Squares Fitting
curl --request POST \
  --url https://finceptbackend.share.zrok.io/quantlib/numerical/least-squares/fit \
  --header 'Content-Type: application/json' \
  --header 'X-API-Key: <api-key>' \
  --data '
{
  "model": "exponential_fit",
  "x_data": [
    0,
    1,
    2,
    3,
    4
  ],
  "y_data": [
    5.1,
    3.8,
    2.9,
    2.3,
    2
  ],
  "x0": [
    5,
    -0.5,
    1.5
  ]
}
'
{
  "success": true,
  "data": {
    "parameters": [
      3.52,
      -0.48,
      1.62
    ],
    "cost": 0.0234,
    "iterations": 12,
    "converged": true
  }
}

Authorizations

X-API-Key
string
header
required

API key for authentication. Get your key at https://finceptbackend.share.zrok.io/auth/register

Body

application/json
model
enum<string>
required

Model type to fit

Available options:
exponential_fit,
polynomial_fit
Example:

"exponential_fit"

x_data
number[]
required

X coordinates of data points

Example:
[0, 1, 2, 3, 4]
y_data
number[]
required

Y coordinates of data points (observations to fit)

Example:
[5.1, 3.8, 2.9, 2.3, 2]
x0
number[]
required

Initial guess for model parameters (exponential: [a,b,c], polynomial: [p0,p1,p2,...])

Example:
[5, -0.5, 1.5]

Response

Successful Response

success
boolean
Example:

true

data
object