NumPhp::logspace

Create a logarithmic range with a defined number of values.

Description

SciPhp\NdArray NumPhp::logspace( mixed $start , mixed $stop [, int $num = 50 ] [, bool $endpoint = true ] [, mixed $base = 10 ])

Parameters

$start
A float or an integer.
$stop
A float or an integer.
$num
An integer. The number of values
$endpoint
A boolean. If True, $base ** $stop is the last element. Otherwise, it is not included. Default is True.
$base
A float or an integer.

Return Values

The new SciPhp\NdArray

Examples

Example #1: A range of 4 values including endpoint, in default base 10

use SciPhp\NumPhp as np;

$x np::logspace(254);

echo 
$x;

The above example will output:

[100     1000    10000   100000]

Example #2: A decreasing range of 4 values including endpoint, in default base 10

use SciPhp\NumPhp as np;

$x np::logspace(524);

echo 
$x;

The above example will output:

[100000  10000   1000    100   ]

Example #3: A range of 4 values excluding endpoint, in default base 10

use SciPhp\NumPhp as np;

$x np::logspace(254false);

echo 
$x;

The above example will output:

[100              562.34132519035  3162.2776601684  17782.794100389]

Example #4: A range of 4 values including endpoint, in base 2

use SciPhp\NumPhp as np;

$x np::logspace(254true2);

echo 
$x;

The above example will output:

[4   8   16  32]

See Also