NumPHP\Core\NumPHP::rand PHP Method

rand() public static method

Returns a NumArray filled with random values
Since: 1.0.0
public static rand ( ) : NumArray
return NumArray
    public static function rand()
    {
        $args = func_get_args();
        return new NumArray(Generate::generateArray($args));
    }

Usage Example

示例#1
0
 /**
  * Tests NumPHP::rand
  */
 public function testRand3()
 {
     $rand = NumPHP::rand(3);
     $this->assertInstanceOf('\\NumPHP\\Core\\NumArray', $rand);
     $this->assertSame([3], $rand->getShape());
     $randData = $rand->getData();
     $this->assertCount(3, $randData);
     foreach ($randData as $entry) {
         $this->assertInternalType('float', $entry);
     }
 }