@theiliad/interpolatejs
Interpolate valueson the go
Last updated 6 months ago by theiliad .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @theiliad/interpolatejs 
SYNC missed versions from official npm registry.

interpolateJS

Lagrange interpolation to the rescue!

license

Intro

InterpolateJS constructs a linear interpolation function p(x) for your provided set of x and y-values, using the Lagrange basis polynomials.

"Lagrange basis polynomials"

Using .evaluate() you can then provide an x-value to the function, and get an interpolated y-value.

Getting started

Installation:

npm i --save @theiliad/interpolatejs

Usage

import/require:

import { interpolation, fraction } from "@theiliad/interpolatejs/index";

const xValues = [fraction(1, 3), fraction(1, 4), 1];
const yValues = [2, -1, 7];
const pOfx = interpolation(xValues, yValues);

console.log("p(1/3) =", pOfx.evaluate(fraction(1, 3)));
// ==> p(1/3) = 2

In-browser CDN Usage:

<script src="https://unpkg.com/@theiliad/interpolatejs"></script>
<script>
const { interpolation, fraction } = interpolateJS;

const xValues = [fraction(1, 3), fraction(1, 4), 1];
const yValues = [2, -1, 7];

const pOfx = interpolation(xValues, yValues);
console.log(
	"p(1/3) =",
	pOfx.evaluate(
		fraction(1, 3)
	)
);
</script>

Current Tags

  • 1.0.6                                ...           latest (6 months ago)

7 Versions

  • 1.0.6                                ...           6 months ago
  • 1.0.5                                ...           6 months ago
  • 1.0.4                                ...           6 months ago
  • 1.0.3                                ...           6 months ago
  • 1.0.2                                ...           6 months ago
  • 1.0.1                                ...           6 months ago
  • 1.0.0                                ...           6 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 2
Last Day 0
Last Week 0
Last Month 7
Dependencies (3)
Dev Dependencies (1)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |