Logspace

Shipping
array_logspace

numpy logspace: base raised to a linspace of exponents (spans base^start … base^stop)

Signature

Outputs

  • arrayArrayA 1-D Vector spanning base^start … base^stop, log-spaced.

Parameters

KeyTypeDefaultNotes
startfloat0.0Exponent of the first value (result = base^start).
stopfloat2.0Exponent of the last value (result = base^stop).
numint50Number of samples.
basefloat10.0The base raised to each exponent (10 = decades, 2 = octaves).
endpointbooleantrueWhen on, the last exponent is exactly Stop.
unittextOptional physical unit for the resulting 1-D Vector.

Description

Logspace is numpy.logspace: it raises Base to each value of a linspace over the exponents StartStop. The result therefore spans to with points evenly spaced on a log scale.

Crucially the Start/Stop parameters are exponents, not the endpoints themselves — set them to and with base to get . Base gives decades, base gives octaves. Under the hood it is base ** linspace(start, stop, num, endpoint), so it inherits linspace's endpoint pinning. If you would rather specify the actual first/last values, use Geomspace.

Mathematics

Examples

Three decades

Start exponent = 0, Stop exponent = 2, Count = 3, Base = 10.

Octave band centres

Base = 2, Start exponent = 0, Stop exponent = 10, Count = 11 (powers of two).

Applications

  • A log-spaced frequency axis for a Bode plot or filter sweep.
  • Decade/octave grids for spectral analysis and audio.
  • Sweeping a gain, time-constant, or hyperparameter across orders of magnitude.

Neat

It is a thin composition: logspace(start, stop, num, base, endpoint) = map(base.powf, linspace(start, stop, num, endpoint)) — so it inherits linspace's exact endpoint pinning on the exponent grid.

A common gotcha it makes explicit in the labels: Start/Stop are EXPONENTS. logspace(0, 2) is 1..100, not 0..2.

Known issues

Start/Stop are exponents, not the literal endpoints — a frequent source of confusion; use Geomspace to give the actual first/last values.

Count is capped at 100,000,000 samples.

See also

arrayvectorsourcenumpylogspacelogarithmicfrequencystateless