3v4l.org

run code in 300+ PHP versions simultaneously
<?php function facdef($n) { switch($n) { case 0: return 1; case 1: return 1; case 2: return 2; case 3: return 6; case 4: return 24; case 5: return 120; case 6: return 720; case 7: return 5040; case 8: return 40320; case 9: return 362880; case 10: return 3628800; case 11: return 39916800; case 12: return 479001600; case 13: return 6227020800; case 14: return 87178291200; case 15: return 1307674368000; case 16: return 20922789888000; case 17: return 355687428096000; case 18: return 6402373705728000; case 19: return 121645100408832000; case 20: return 2432902008176640000; case 21: return 51090942171709440000; case 22: return 1124000727777607680000; case 23: return 25852016738884976640000; } } function constify($a) { #regression constants return $a*0.424+0.548; } function scorefix($avg) { #if predicted score is small or negative, return something reasonable if ( $avg < 0.01 ) { return pow(10,(pow(10,$avg-1))) / 105.50984676065602; } else { return $avg; } } function sim($homeoff,$homedef,$awayoff,$awaydef,$mul,$natavg) { #returns homemu,awaymu for poisson to deal with return array(scorefix((($homeoff-$natavg)*max(constify($awaydef*$mul),0.25)/constify($natavg*$mul)+$awaydef)*$mul),scorefix((($homedef-$natavg)*max(constify($awayoff/$mul),0.25)/constify($natavg/$mul)+$awayoff)/$mul)); } function poisson($mu,$shift) { #returns array of poisson probabilities for scores $x = []; for ($i = 1 ; $i <= $shift ; $i++ ) { array_push($x,0.0); } $pcdf = 0.0; $a = exp(-1*$mu); echo count($a); while ( $pcdf < 0.999999 || count($x) < 5 ) { echo pow($mu,(count($x)-$shift))."\n"; echo facdef(count($x)-$shift)."\n"; array_push($x,$a*(pow($mu,(count($x)-$shift)))/facdef(count($x)-$shift)); echo count($x); $pcdf+=end($x); } return $x; } var_dump(poisson(1.1,0)); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/k7dXn
function name:  (null)
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   86     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'poisson'
          2        SEND_VAL                                                 1.1
          3        SEND_VAL                                                 0
          4        DO_FCALL                                      0  $0      
          5        SEND_VAR                                                 $0
          6        DO_ICALL                                                 
   88     7      > RETURN                                                   1

Function facdef:
Finding entry points
Branch analysis from position: 0
26 jumps found. (Code = 187) Position 1 = 51, Position 2 = 52, Position 3 = 53, Position 4 = 54, Position 5 = 55, Position 6 = 56, Position 7 = 57, Position 8 = 58, Position 9 = 59, Position 10 = 60, Position 11 = 61, Position 12 = 62, Position 13 = 63, Position 14 = 64, Position 15 = 65, Position 16 = 66, Position 17 = 67, Position 18 = 68, Position 19 = 69, Position 20 = 70, Position 21 = 71, Position 22 = 72, Position 23 = 73, Position 24 = 74, Position 25 = 75, Position 26 = 2
Branch analysis from position: 51
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 52
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 53
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 54
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 55
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 56
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 57
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 58
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 59
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 60
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 61
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 62
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 63
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 64
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 65
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 66
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 67
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 68
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 69
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 70
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 71
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 72
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 73
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 74
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 75
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
2 jumps found. (Code = 44) Position 1 = 4, Position 2 = 51
Branch analysis from position: 4
2 jumps found. (Code = 44) Position 1 = 6, Position 2 = 52
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 8, Position 2 = 53
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 54
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 55
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 56
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 57
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 58
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 59
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 60
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 61
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 62
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 28, Position 2 = 63
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 64
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 65
Branch analysis from position: 32
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 66
Branch analysis from position: 34
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 67
Branch analysis from position: 36
2 jumps found. (Code = 44) Position 1 = 38, Position 2 = 68
Branch analysis from position: 38
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 69
Branch analysis from position: 40
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 70
Branch analysis from position: 42
2 jumps found. (Code = 44) Position 1 = 44, Position 2 = 71
Branch analysis from position: 44
2 jumps found. (Code = 44) Position 1 = 46, Position 2 = 72
Branch analysis from position: 46
2 jumps found. (Code = 44) Position 1 = 48, Position 2 = 73
Branch analysis from position: 48
2 jumps found. (Code = 44) Position 1 = 50, Position 2 = 74
Branch analysis from position: 50
1 jumps found. (Code = 42) Position 1 = 75
Branch analysis from position: 75
Branch analysis from position: 74
Branch analysis from position: 73
Branch analysis from position: 72
Branch analysis from position: 71
Branch analysis from position: 70
Branch analysis from position: 69
Branch analysis from position: 68
Branch analysis from position: 67
Branch analysis from position: 66
Branch analysis from position: 65
Branch analysis from position: 64
Branch analysis from position: 63
Branch analysis from position: 62
Branch analysis from position: 61
Branch analysis from position: 60
Branch analysis from position: 59
Branch analysis from position: 58
Branch analysis from position: 57
Branch analysis from position: 56
Branch analysis from position: 55
Branch analysis from position: 54
Branch analysis from position: 53
Branch analysis from position: 52
Branch analysis from position: 51
filename:       /in/k7dXn
function name:  facdef
number of ops:  76
compiled vars:  !0 = $n
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1      > SWITCH_LONG                                              !0, [ 0:->51, 1:->52, 2:->53, 3:->54, 4:->55, 5:->56, 6:->57, 7:->58, 8:->59, 9:->60, 10:->61, 11:->62, 12:->63, 13:->64, 14:->65, 15:->66, 16:->67, 17:->68, 18:->69, 19:->70, 20:->71, 21:->72, 22:->73, 23:->74, ], ->75
    4     2    >   IS_EQUAL                                                 !0, 0
          3      > JMPNZ                                                    ~1, ->51
    6     4    >   IS_EQUAL                                                 !0, 1
          5      > JMPNZ                                                    ~1, ->52
    8     6    >   IS_EQUAL                                                 !0, 2
          7      > JMPNZ                                                    ~1, ->53
   10     8    >   IS_EQUAL                                                 !0, 3
          9      > JMPNZ                                                    ~1, ->54
   12    10    >   IS_EQUAL                                                 !0, 4
         11      > JMPNZ                                                    ~1, ->55
   14    12    >   IS_EQUAL                                                 !0, 5
         13      > JMPNZ                                                    ~1, ->56
   16    14    >   IS_EQUAL                                                 !0, 6
         15      > JMPNZ                                                    ~1, ->57
   18    16    >   IS_EQUAL                                                 !0, 7
         17      > JMPNZ                                                    ~1, ->58
   20    18    >   IS_EQUAL                                                 !0, 8
         19      > JMPNZ                                                    ~1, ->59
   22    20    >   IS_EQUAL                                                 !0, 9
         21      > JMPNZ                                                    ~1, ->60
   24    22    >   IS_EQUAL                                                 !0, 10
         23      > JMPNZ                                                    ~1, ->61
   26    24    >   IS_EQUAL                                                 !0, 11
         25      > JMPNZ                                                    ~1, ->62
   28    26    >   IS_EQUAL                                                 !0, 12
         27      > JMPNZ                                                    ~1, ->63
   30    28    >   IS_EQUAL                                                 !0, 13
         29      > JMPNZ                                                    ~1, ->64
   32    30    >   IS_EQUAL                                                 !0, 14
         31      > JMPNZ                                                    ~1, ->65
   34    32    >   IS_EQUAL                                                 !0, 15
         33      > JMPNZ                                                    ~1, ->66
   36    34    >   IS_EQUAL                                                 !0, 16
         35      > JMPNZ                                                    ~1, ->67
   38    36    >   IS_EQUAL                                                 !0, 17
         37      > JMPNZ                                                    ~1, ->68
   40    38    >   IS_EQUAL                                                 !0, 18
         39      > JMPNZ                                                    ~1, ->69
   42    40    >   IS_EQUAL                                                 !0, 19
         41      > JMPNZ                                                    ~1, ->70
   44    42    >   IS_EQUAL                                                 !0, 20
         43      > JMPNZ                                                    ~1, ->71
   46    44    >   IS_EQUAL                                                 !0, 21
         45      > JMPNZ                                                    ~1, ->72
   48    46    >   IS_EQUAL                                                 !0, 22
         47      > JMPNZ                                                    ~1, ->73
   50    48    >   IS_EQUAL                                                 !0, 23
         49      > JMPNZ                                                    ~1, ->74
         50    > > JMP                                                      ->75
    5    51    > > RETURN                                                   1
    7    52    > > RETURN                                                   1
    9    53    > > RETURN                                                   2
   11    54    > > RETURN                                                   6
   13    55    > > RETURN                                                   24
   15    56    > > RETURN                                                   120
   17    57    > > RETURN                                                   720
   19    58    > > RETURN                                                   5040
   21    59    > > RETURN                                                   40320
   23    60    > > RETURN                                                   362880
   25    61    > > RETURN                                                   3628800
   27    62    > > RETURN                                                   39916800
   29    63    > > RETURN                                                   479001600
   31    64    > > RETURN                                                   6227020800
   33    65    > > RETURN                                                   87178291200
   35    66    > > RETURN                                                   1307674368000
   37    67    > > RETURN                                                   20922789888000
   39    68    > > RETURN                                                   355687428096000
   41    69    > > RETURN                                                   6402373705728000
   43    70    > > RETURN                                                   121645100408832000
   45    71    > > RETURN                                                   2432902008176640000
   47    72    > > RETURN                                                   5.10909e+19
   49    73    > > RETURN                                                   1.124e+21
   51    74    > > RETURN                                                   2.5852e+22
   53    75    > > RETURN                                                   null

End of function facdef

Function constify:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/k7dXn
function name:  constify
number of ops:  5
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   55     0  E >   RECV                                             !0      
   56     1        MUL                                              ~1      !0, 0.424
          2        ADD                                              ~2      ~1, 0.548
          3      > RETURN                                                   ~2
   57     4*     > RETURN                                                   null

End of function constify

Function scorefix:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 15
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/k7dXn
function name:  scorefix
number of ops:  17
compiled vars:  !0 = $avg
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   59     0  E >   RECV                                             !0      
   60     1        IS_SMALLER                                               !0, 0.01
          2      > JMPZ                                                     ~1, ->15
          3    >   INIT_FCALL                                               'pow'
          4        SEND_VAL                                                 10
          5        INIT_FCALL                                               'pow'
          6        SEND_VAL                                                 10
          7        SUB                                              ~2      !0, 1
          8        SEND_VAL                                                 ~2
          9        DO_ICALL                                         $3      
         10        SEND_VAR                                                 $3
         11        DO_ICALL                                         $4      
         12        DIV                                              ~5      $4, 105.51
         13      > RETURN                                                   ~5
         14*       JMP                                                      ->16
   61    15    > > RETURN                                                   !0
   62    16*     > RETURN                                                   null

End of function scorefix

Function sim:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/k7dXn
function name:  sim
number of ops:  50
compiled vars:  !0 = $homeoff, !1 = $homedef, !2 = $awayoff, !3 = $awaydef, !4 = $mul, !5 = $natavg
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   64     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
          4        RECV                                             !4      
          5        RECV                                             !5      
   65     6        INIT_FCALL                                               'scorefix'
          7        SUB                                              ~6      !0, !5
          8        INIT_FCALL                                               'max'
          9        INIT_FCALL                                               'constify'
         10        MUL                                              ~7      !3, !4
         11        SEND_VAL                                                 ~7
         12        DO_FCALL                                      0  $8      
         13        SEND_VAR                                                 $8
         14        SEND_VAL                                                 0.25
         15        DO_ICALL                                         $9      
         16        MUL                                              ~10     $9, ~6
         17        INIT_FCALL                                               'constify'
         18        MUL                                              ~11     !5, !4
         19        SEND_VAL                                                 ~11
         20        DO_FCALL                                      0  $12     
         21        DIV                                              ~13     ~10, $12
         22        ADD                                              ~14     ~13, !3
         23        MUL                                              ~15     !4, ~14
         24        SEND_VAL                                                 ~15
         25        DO_FCALL                                      0  $16     
         26        INIT_ARRAY                                       ~17     $16
         27        INIT_FCALL                                               'scorefix'
         28        SUB                                              ~18     !1, !5
         29        INIT_FCALL                                               'max'
         30        INIT_FCALL                                               'constify'
         31        DIV                                              ~19     !2, !4
         32        SEND_VAL                                                 ~19
         33        DO_FCALL                                      0  $20     
         34        SEND_VAR                                                 $20
         35        SEND_VAL                                                 0.25
         36        DO_ICALL                                         $21     
         37        MUL                                              ~22     $21, ~18
         38        INIT_FCALL                                               'constify'
         39        DIV                                              ~23     !5, !4
         40        SEND_VAL                                                 ~23
         41        DO_FCALL                                      0  $24     
         42        DIV                                              ~25     ~22, $24
         43        ADD                                              ~26     ~25, !2
         44        DIV                                              ~27     ~26, !4
         45        SEND_VAL                                                 ~27
         46        DO_FCALL                                      0  $28     
         47        ADD_ARRAY_ELEMENT                                ~17     $28
         48      > RETURN                                                   ~17
   66    49*     > RETURN                                                   null

End of function sim

Function poisson:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 5
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 59
Branch analysis from position: 59
2 jumps found. (Code = 47) Position 1 = 61, Position 2 = 64
Branch analysis from position: 61
2 jumps found. (Code = 44) Position 1 = 65, Position 2 = 21
Branch analysis from position: 65
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
2 jumps found. (Code = 47) Position 1 = 61, Position 2 = 64
Branch analysis from position: 61
Branch analysis from position: 64
Branch analysis from position: 64
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 5
Branch analysis from position: 12
Branch analysis from position: 5
filename:       /in/k7dXn
function name:  poisson
number of ops:  67
compiled vars:  !0 = $mu, !1 = $shift, !2 = $x, !3 = $i, !4 = $pcdf, !5 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   68     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   69     2        ASSIGN                                                   !2, <array>
   70     3        ASSIGN                                                   !3, 1
          4      > JMP                                                      ->10
   71     5    >   INIT_FCALL                                               'array_push'
          6        SEND_REF                                                 !2
          7        SEND_VAL                                                 0
          8        DO_ICALL                                                 
   70     9        PRE_INC                                                  !3
         10    >   IS_SMALLER_OR_EQUAL                                      !3, !1
         11      > JMPNZ                                                    ~10, ->5
   73    12    >   ASSIGN                                                   !4, 0
   74    13        INIT_FCALL                                               'exp'
         14        MUL                                              ~12     !0, -1
         15        SEND_VAL                                                 ~12
         16        DO_ICALL                                         $13     
         17        ASSIGN                                                   !5, $13
   75    18        COUNT                                            ~15     !5
         19        ECHO                                                     ~15
   76    20      > JMP                                                      ->59
   77    21    >   INIT_FCALL                                               'pow'
         22        SEND_VAR                                                 !0
         23        COUNT                                            ~16     !2
         24        SUB                                              ~17     ~16, !1
         25        SEND_VAL                                                 ~17
         26        DO_ICALL                                         $18     
         27        CONCAT                                           ~19     $18, '%0A'
         28        ECHO                                                     ~19
   78    29        INIT_FCALL                                               'facdef'
         30        COUNT                                            ~20     !2
         31        SUB                                              ~21     ~20, !1
         32        SEND_VAL                                                 ~21
         33        DO_FCALL                                      0  $22     
         34        CONCAT                                           ~23     $22, '%0A'
         35        ECHO                                                     ~23
   79    36        INIT_FCALL                                               'array_push'
         37        SEND_REF                                                 !2
         38        INIT_FCALL                                               'pow'
         39        SEND_VAR                                                 !0
         40        COUNT                                            ~24     !2
         41        SUB                                              ~25     ~24, !1
         42        SEND_VAL                                                 ~25
         43        DO_ICALL                                         $26     
         44        MUL                                              ~27     !5, $26
         45        INIT_FCALL                                               'facdef'
         46        COUNT                                            ~28     !2
         47        SUB                                              ~29     ~28, !1
         48        SEND_VAL                                                 ~29
         49        DO_FCALL                                      0  $30     
         50        DIV                                              ~31     ~27, $30
         51        SEND_VAL                                                 ~31
         52        DO_ICALL                                                 
   80    53        COUNT                                            ~33     !2
         54        ECHO                                                     ~33
   81    55        INIT_FCALL                                               'end'
         56        SEND_REF                                                 !2
         57        DO_ICALL                                         $34     
         58        ASSIGN_OP                                     1          !4, $34
   76    59    >   IS_SMALLER                                       ~36     !4, 0.999999
         60      > JMPNZ_EX                                         ~36     ~36, ->64
         61    >   COUNT                                            ~37     !2
         62        IS_SMALLER                                       ~38     ~37, 5
         63        BOOL                                             ~36     ~38
         64    > > JMPNZ                                                    ~36, ->21
   83    65    > > RETURN                                                   !2
   84    66*     > RETURN                                                   null

End of function poisson

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.75 ms | 1423 KiB | 34 Q