@quri/metalog
TypeScript icon, indicating that this package has built-in type declarations

1.2.11 • Public • Published

@quri/metalog

This package is a JS implementation of metalog. It is based on rmetalog but varies in a couple of ways.

  1. rmetalog doesn't seem to strictly obey the cdf being the inverse of the quantile function. As far as I can tell, around the tails it doesn't hold this inverse perfectly. This implementation is built to hold that inverse better.
  2. rmetalog is slower. They use newton's method but to prevent non-convergence, they take smaller steps towards the solution. This makes the code do more iterations to converge.

Utilising the fact that we are doing newton's method on a monotonic function (a quantile function), I use a mixture of binary search and newton's method to converge on a solution quickly. My implementation is both faster and more accurate.

There are some problems with this implementation, most notably:

  1. Because we approximate the cdf with newton's method, the function is not strictly monotonic. A solution to this would be really difficult. I would need to work out how to iterate to the next highest float, and make sure the other functions floating point arithmetic is as accurate as possible.

Usage

import { quantile } from "@quri/metalog"

quantile([1, 2, 3], 0.5)
cdf([1, 2, 3], 0)
pdf([1, 2, 3], 0)\

The first argument is an array of the distributions a parameter. See Metalog Distribution for details.

Readme

Keywords

none

Package Sidebar

Install

npm i @quri/metalog

Weekly Downloads

0

Version

1.2.11

License

ISC

Unpacked Size

1.57 MB

Total Files

22

Last publish

Collaborators

  • berekuk
  • oagr
  • nunosempere
  • quinnd
  • hazelfire