treetime-ca / scientist-chances-fractional
A fractional chance class for daylerees/scientist
0.1.2
2021-08-17 16:41 UTC
Requires
- php: >=7.3
- daylerees/scientist: ^2.1
Requires (Dev)
This package is auto-updated.
Last update: 2024-11-09 05:20:59 UTC
README
Scientist Fractional Chance
Fractional chance class for use with the Scientist Library
1. Installation
Require the latest version of Scientist Chances Fractional using Composer.
composer require treetime-ca/scientist-chances-fractional
2. Usage
Using FractionalChance for experiment to run only 1 out of 100 times
$chance = new FractionalChance(); // Setting experiment to run 1%, 1/100 times, default 1 out of value sent to setProbability $chance->setProbability(100); // Explicitly setting probability to 1% or 1/100 chance $chance->setProbability(100, 1); $experiment = (new Scientist\Laboratory) ->experiment('experiment title') ->control($controlCallback) ->chance($chance) ->trial('trial name', $trialCallback) ->matcher($matcher);
Using FractionalChance for experiment to run 33.3%, 1/3 of the time
$chance = new FractionalChance(); $chance->setProbability(3,1); $experiment = (new Scientist\Laboratory) ->experiment('experiment title') ->control($controlCallback) ->chance($chance) ->trial('trial name', $trialCallback) ->matcher($matcher);