New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bayesian-bandit

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bayesian-bandit

Bayesian bandit implementation for Node and the browser.

  • 0.9.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
18
increased by157.14%
Maintainers
1
Weekly downloads
 
Created
Source

#bayesian-bandit.js

This is an adaptation of the Bayesian Bandit code from Probabilistic Programming and Bayesian Methods for Hackers, specifically d3bandits.js.

The code has been rewritten to be more idiomatic and also usable as a browser script or npm package. Additionally, unit tests are included.

#Quick Start

From node.js:

npm install bayesian-bandit
node

Then:

var Bandit = require('bayesian-bandit').Bandit

In the browser:

<script src="https://raw.github.com/omphalos/bayesian-bandit.js/master/bayesian-bandit.js"></script>

Sample JavaScript:

var bandit = new Bandit({ numberOfArms: 2 })

bandit.arms[0].reward(0) // Arm 0 loses once.
bandit.arms[0].reward(1) // Arm 0 wins once.

bandit.arms[1].reward(0) // Arm 1 loses once.
bandit.arms[1].reward(1) // Arm 1 wins once.
bandit.arms[1].reward(1) // Arm 1 wins twice.

bandit.selectArm() // Arm 1 is more likely, so this probably returns 1

#Unit Tests

The unit tests use nodeunit. You can set that up by typing:

npm install -g nodeunit

Then you can run unit tests with:

nodeunit tests.js

Keywords

FAQs

Package last updated on 19 Aug 2013

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc