0.1.2 • Published 4 years ago

bayesian-bandits v0.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

Bayesian Bandits

References:

Quick Start:

In the root of your folder run yarn add bayesian-bandits to install the package.

Inside your JS/TS files:

// Example to help Megan choose what chocolate to buy for maximum enjoyment
// without making it completely impossible for tastes to change
import { chooseArm, rewardArm, bernoulli } from 'bayesian-bandits';

const candies = {
  arms: [
    {
      attempts: 20,
      sum: 10,
      name: 'Twix',
    },
    {
      attempts: 20,
      sum: 18,
      name: 'Recees',
    },
    {
      attempts: 20,
      sum: 14,
      name: 'Top Deck',
    },
    {
      attempts: 20,
      sum: 1,
      name: 'Mounds',
    },
  ],
};

// To choose the arm you want to pull
const armIndex = chooseArm(banditState.arms);

// Deremine the reward for the arm based on your application logic
const armReward = 1;

// Number of total attemts that resulted in the above reward
const armReward = 1;

const updatedBanditArms = rewardArm(
  candies.arms,
  armIndex,
  armReward,
  attempts
);

// Store the updated Bandit Arms in state ready for reuse later on.
storeSomethingMethod(updatedBandits);

License

MIT

0.1.2

4 years ago

0.1.1

4 years ago