New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@sctg/polyfitjs

Package Overview
Dependencies
Maintainers
0
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sctg/polyfitjs

Polynomial fitment library for javascript

latest
Source
npmnpm
Version
0.0.3
Version published
Maintainers
0
Created
Source

@sctg/polyfitjs

Build npm version

A TypeScript library for polynomial fitting.

Features

  • Polynomial fitting up to n degrees
  • Support for Array, Float32Array and Float64Array
  • Correlation coefficient calculation
  • Standard error calculation
  • Polynomial expression generation

Installation

npm install @sctg/polyfitjs

Usage

Creating a polynomial function

import { Polyfit } from '@sctg/polyfitjs';

const x = [1, 2, 3, 4, 5];
const y = [0.01, 0.03, -0.02, 0.03, 0.02];
const poly = new Polyfit(x, y);
const solver = poly.getPolynomial(6);

// Using the solver
console.log(solver(1.17)); // Calculates y for x = 1.17

Getting coefficients

const terms = poly.computeCoefficients(6);
console.log(terms); // Shows polynomial coefficients

Finding the best fit for a given correlation coefficient

const terms = poly.computeBestFit(100,0.99); // Max degree, min correlation coefficient
console.log(terms); // Shows polynomial coefficients

Computing statistical metrics

const terms = poly.computeCoefficients(6);
const correlation = poly.correlationCoefficient(terms);
const stdError = poly.standardError(terms);

Building

To build the project, run the following command:

  git clone git@github.com:sctg-development/polyfitjs.git
  cd polyfitjs
  npm ci
  npm run build
  npm test

License

Copyright © 2023, P. Lutus and Ryan Fink.
Modifications © 2025, SCTG Development. Released under GPL v3 - Details

Acknowledgments

Heavily inspired by Paul Lutus's work (lutusp@arachnoid.com) - polysolve

FAQs

Package last updated on 06 Feb 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts