Skip to content

Esta página también está en español.

Léela en español

このページは日本語でも読めます。

日本語で読む

本页也有简体中文版本。

阅读简体中文版本

fit function

The least-squares fit of a combination of functions through points.

How to write it

fit(points, basis, x)

The combination whose squared distances to the points add up the least.

points
The points, as a list of pairs [x, y]. Takes a list.
basis
The functions to combine, in x, such as [1, x, x^2]. Takes a list.
x
The variable of the basis. Takes a variable.

fit(points, basis, x, distance = 1|2|inf)

The combination whose deviations from the points are least in that distance, when exactly one combination is.

points
The points, as a list of pairs [x, y]. Takes a list.
basis
The functions to combine, in x, such as [1, x, x^2]. Takes a list.
x
The variable of the basis. Takes a variable.
distance = 1|2|inf
Which deviations count: 1 their sum, 2 the sum of their squares (the default), inf the largest.

Examples

  • (0,1),(1,3),(2,5),(3,8)=23x10+45\displaystyle (0, 1), (1, 3), (2, 5), (3, 8) = \frac{23 x}{10}+\frac{4}{5}
    fit([[0, 1], [1, 3], [2, 5], [3, 8]], [1, x], x)

    In the solver, fit([[0, 1], [1, 3], [2, 5], [3, 8]], [1, x], x) gives 23x/10 + 4/5.

    Open in the solver
  • (0,1),(1,3),(2,5),(3,8) by {1,x,x2}=x24+31x20+2120\displaystyle (0, 1), (1, 3), (2, 5), (3, 8) \text{ by } \left\{ 1, x, x^{2} \right\} = \frac{x^{2}}{4}+\frac{31 x}{20}+\frac{21}{20}
    fit([[0, 1], [1, 3], [2, 5], [3, 8]], [1, x, x^2], x)

    In the solver, fit([[0, 1], [1, 3], [2, 5], [3, 8]], [1, x, x^2], x) gives x^2/4 + 31x/20 + 21/20.

    Open in the solver
  • (0,0),(1,1),(2,2),(3,3),(4,10)=x\displaystyle (0, 0), (1, 1), (2, 2), (3, 3), (4, 10) = x
    fit([[0, 0], [1, 1], [2, 2], [3, 3], [4, 10]], [1, x], x, distance = 1)

    In the solver, fit([[0, 0], [1, 1], [2, 2], [3, 3], [4, 10]], [1, x], x, distance = 1) gives x.

    Open in the solver
  • (0,0),(1,1),(2,2),(3,3),(4,10)=5x2−94\displaystyle (0, 0), (1, 1), (2, 2), (3, 3), (4, 10) = \frac{5 x}{2}-\frac{9}{4}
    fit([[0, 0], [1, 1], [2, 2], [3, 3], [4, 10]], [1, x], x, distance = inf)

    In the solver, fit([[0, 0], [1, 1], [2, 2], [3, 3], [4, 10]], [1, x], x, distance = inf) gives 5x/2 - 9/4.

    Open in the solver
  • geometric_brownian_motion_process

    A process that grows at rate mu with relative noise sigma, started at x0.

  • exponential_distribution

    The waiting time for events that come at rate lambda.

  • geometric_sde_path

    The path of dX = mu X dt + sigma X dW, as a function of the Wiener process's value w at time t.

  • expectation

    The expected value of an expression of a variable with a distribution or a process.

  • ito_formula

    Itô's lemma: the differential of an expression of states that follow an Itô process.

  • distributed

    A variable and the distribution it follows, as probability and expectation read it.