Logspace
Shippingarray_logspacenumpy logspace: base raised to a linspace of exponents (spans base^start … base^stop)
Signature
Outputs
arrayArray— A 1-D Vector spanning base^start … base^stop, log-spaced.
Parameters
| Key | Type | Default | Notes |
|---|---|---|---|
start | float | 0.0 | Exponent of the first value (result = base^start). |
stop | float | 2.0 | Exponent of the last value (result = base^stop). |
num | int | 50 | Number of samples. |
base | float | 10.0 | The base raised to each exponent (10 = decades, 2 = octaves). |
endpoint | boolean | true | When on, the last exponent is exactly Stop. |
unit | text | Optional 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 Start … Stop. 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.