Have ideas to improve npm?Join in the discussion! »

    probability-table

    1.0.2 • Public • Published

    probability-table

    An easy way to handle probability lookup tables

    import Table = from 'probability-table';
    
    let	inst = new Table(),
    	outcome;
    
    // Percentage and the value to return 
    inst.add(50,'heads');
    inst.add(50,'tails');
    
    
    //Accepts a number from 0 - 1 exclusive
    // "tails" || "heads"
    outcome = inst.get(Math.random());
    
    inst.clear();
    //The total probability need not add up to 100%
    inst.add(50,'heads');
    
    // null || "heads"
    outcome = inst.get(Math.random());
    
    //Probability tables can use double as their probabilities
    inst.add(99.9999,'house_wins');
    inst.add(0.0001,'you_win');

    Install

    npm i probability-table

    DownloadsWeekly Downloads

    3

    Version

    1.0.2

    License

    MIT

    Unpacked Size

    5.44 kB

    Total Files

    4

    Last publish

    Collaborators

    • avatar
    • avatar