verisimiltude - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of verisimiltude.php

  1. <?php
  2. function vesimilitud($mean){
  3.     
  4.     $pi= 3.1416;
  5.     $sd = 10;
  6.     //$mean = 20; // cambiar esto pr ej. (30,40,50,60)
  7.     
  8.     $answer = [];
  9.     foreach ([38.6, 42.4, 57.5, 40.5, 51.7, 67.1, 33.4, 60.9, 64.1, 40.1, 40.7, 6.4 ] as $val){
  10.         $value =  exp(-1/2* pow((($val-$mean)/$sd ),2));
  11.         array_push($answer,$value);
  12.     
  13.     }
  14.      $value2 = 1/sqrt(2*$pi*$sd);
  15.     array_push($answer,$value2);
  16.     
  17.     return array_product($answer);
  18. }
  19.  
  20. foreach(array(20,30,40,50,60,70) as $key=>$value){
  21.     echo "L(".$value.")=".vesimilitud($value).PHP_EOL;
  22. }
File Description
  • verisimiltude
  • PHP Code
  • 18 Nov-2017
  • 566 Bytes
You can Share it: