Skip to content

Commit

Permalink
Datafit v1.0.1 (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicfv authored Mar 9, 2024
1 parent c458b69 commit b25cbdd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions datafit/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 1.0.1

- Minor readme fixes

## 1.0.0

- Do not require all configuration options for `fit()`
Expand Down
6 changes: 4 additions & 2 deletions datafit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,15 @@ const a = bestFit.params,

My results were about `a2 = -1, a1 = 5.3, a0 = -3.5`, which means my best-fit function is `y = -x^2 + 5.3x - 3.5`. Try it for yourself and see if you obtain similar results!

In this example, the x values for our data points are given as 1, 2, 3, and 4. If we interpolate within this range, the model will be very accurate, but less and less so, if we extrapolate very far beyond either end of this range.
In this example, the x values for our data points are given as 1, 2, 3, and 4. If we interpolate within this range, the model will be very accurate. Extrapolating very far beyond either end of this range will probably not be very accurate!

> Mind the order of your function parameters! `fit()` will output a parameter array that follows the same order as the function parameters, even if it is non-intuitive! For example, if my function signature looks like `f(x, a2, a1, a0)`, then `bestFit.params` would return an array `[a2, a1, a0]`. You would access `a2` with `a[0]`!
### Multivariate

In this slightly more complicated example, we'll define a 2D planar function to fit 3-dimensional data. The main difference here is that `x` is now an array, in both `f(x)` and the dataset, but everything else is functionally the same!

Don't get tricked here with the dataset. The `x` property refers to all the *inputs* to the function, and the `y` property refers to all the *outputs*. In this example, `x` is an array of length 2, representing our 2 independent dimensions. We can call those dimensions `x` and `y`, obtained by `x[0]` and `y[0]` respectively, however, in mathematics, this is simply referred to as the `X` vector. In this example, the `y` property in our dataset could actually be our z-axis. It's important to remember that the `x` and `y` properties in the dataset simply refer to the *inputs* and *outputs* of the function, not necessarily the x- and y-axes.
Don't get tricked here with the dataset. The `x` property refers to all the *inputs* to the function, and the `y` property refers to the *output*. In this example, `x` is an array of length 2, representing our 2 independent dimensions. We can call those dimensions the x-axis and y-axis, obtained by `x[0]` and `x[1]` respectively, however, in mathematics, this is simply referred to as the `X` vector. In this example, the `y` property in our dataset could actually be our z-axis. It's important to remember that the `x` and `y` properties in the dataset simply refer to the *inputs* and *output* of the function, not necessarily the x-axis and y-axis.

```js
import { fit } from 'datafit';
Expand Down
2 changes: 1 addition & 1 deletion datafit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "datafit",
"version": "1.0.0",
"version": "1.0.1",
"description": "Simple curve-fitting algorithm",
"main": "dist/index.js",
"types": "types/index.d.ts",
Expand Down

0 comments on commit b25cbdd

Please sign in to comment.