Socket
Book a DemoInstallSign in
Socket

suprisal

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

suprisal

Compute the suprisal of an event given its probability.

latest
Source
npmnpm
Version
1.0.4
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

suprisal

Compute the suprisal of an event given its probability.

Installation

npm i suprisal

Usage

import suprisal from 'suprisal'

suprisal(0.5) // returns 1.0

suprisal(1.0) // returns 0.0

suprisal(0.0) // returns Infinity

Suprisal is given in bits (base 2) by default, however you can also specify other bases via the second argument. For example, to compute suprisal in nats (base 10):

suprisal(0.5, base=10) // returns 0.301

Keywords

suprisal

FAQs

Package last updated on 03 Feb 2023

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