Beispiel #1
0
 /**
  * Computes the population standard deviation for the numbers
  * in this list
  * @return string
  */
 public function stdDev()
 {
     Number::setScale(static::NUMERIC_FUNCTIONS_SCALE);
     $mean = $this->average();
     $squares = new static();
     foreach ($this->_Arr as $num) {
         $squares->add(Number::pow(Number::sub(\strval($num), $mean), '2'));
     }
     return Number::sqrt($squares->average());
 }
Beispiel #2
0
 /**
  * Converts the set to an integer string. The difference between this
  * and toInt() is that this method uses bcmath functions to handle
  * large bit sets that would fail to properly be converted to a PHP
  * integer if toInt() is used.
  * @return string
  */
 public function toLongInt()
 {
     $total = '0';
     for ($i = 0, $l = $this->count(); $i < $l; ++$i) {
         if ($this->_List[$i]) {
             $total = Number::add($total, Number::pow('2', (string) $i));
         }
     }
     return $total;
 }
Beispiel #3
0
 public function testPow()
 {
     $l = '65';
     $r = '21';
     $exp = '117809547936177440979200839996337890625';
     $this->assertEquals($exp, Number::pow($l, $r));
 }