Socket
Socket
Sign inDemoInstall

w-distributions

Package Overview
Dependencies
1
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    w-distributions

Distributions for Uniform, Normal, Binomial and Studentt, fork from distributions.


Version published
Weekly downloads
1
decreased by-83.33%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

w-distributions

Distributions for Uniform, Normal, Binomial and Studentt, fork from distributions.

language npm version Build Status license gzip file size npm download jsdelivr download

Documentation

To view documentation or get support, visit docs.

Example

To view some examples for more understanding, visit examples:

distributions: web [source code]

Installation

Using npm(ES6 module):

Note: w-distributions is mainly dependent on cephes.

npm i w-distributions
Example:
import wd from 'w-distributions'

async function test() {
    let r

    let normal = await wd.Normal(1,2) //mean=1,std deviation=2

    r = normal.pdf(1)
    console.log(r)
    // => 0.19947114020071632

    r = normal.cdf(1)
    console.log(r)
    // => 0.5

    r = normal.inv(1)
    console.log(r)
    // => Infiniy

    r = normal.mean()
    console.log(r)
    // => 1

    r = normal.median()
    console.log(r)
    // => 1

    r = normal.variance()
    console.log(r)
    // => 4

    let studentt = await wd.Studentt(34) //degrees of freedom=34

    r = studentt.inv(0.95) //one or two sided test p-values=0.95
    console.log(r)
    // => 1.6909242551868549

    studentt = await wd.Studentt(4) //degrees of freedom=4

    r = studentt.inv(0.05) //one or two sided test p-values=0.05
    console.log(r)
    // => -2.1318467863266504

}
test()
    .catch((err) => {
        console.log(err)
    })

In a browser(UMD module):

Note: w-distributions is not dependent on any package, has included cephes.

Note: It does not support IE11, because cephes using WebAssembly in the browser.

[Necessary] Add script for w-distributions.

<script src="https://cdn.jsdelivr.net/npm/w-distributions@1.0.2/dist/w-distributions.umd.js"></script>
Example:

Link: [dev source code]

<script>

    let wd = window['w-distributions']
    // console.log('wd',wd)

    async function test() {
        let r

        let normal = await wd.Normal(1, 2) //mean=1,std deviation=2

        r = normal.pdf(1)
        console.log(r)
        // => 0.19947114020071632

        r = normal.cdf(1)
        console.log(r)
        // => 0.5

        r = normal.inv(1)
        console.log(r)
        // => Infiniy

        r = normal.mean()
        console.log(r)
        // => 1

        r = normal.median()
        console.log(r)
        // => 1

        r = normal.variance()
        console.log(r)
        // => 4

        let studentt = await wd.Studentt(34) //degrees of freedom=34

        r = studentt.inv(0.95) //one or two sided test p-values=0.95
        console.log(r)
        // => 1.6909242551868549

        studentt = await wd.Studentt(4) //degrees of freedom=4

        r = studentt.inv(0.05) //one or two sided test p-values=0.05
        console.log(r)
        // => -2.1318467863266504

    }
    test()
        .catch((err) => {
            console.log(err)
        })

</script>

Keywords

FAQs

Last updated on 15 Apr 2021

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc