PHP code example of arcticlinux / scientist-chances-fractional

1. Go to this page and download the library: Download arcticlinux/scientist-chances-fractional library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

arcticlinux / scientist-chances-fractional example snippets


$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);

$chance = new FractionalChance();
$chance->setProbability(3,1);
$experiment = (new Scientist\Laboratory)
  ->experiment('experiment title')
  ->control($controlCallback)
  ->chance($chance)
  ->trial('trial name', $trialCallback)
  ->matcher($matcher);