Linspace

Shipping
array_linspace

numpy linspace: num evenly-spaced samples from start to stop with a pinned endpoint

Signature

Outputs

  • arrayArrayA 1-D Vector of num linearly-spaced samples from start to stop.

Parameters

KeyTypeDefaultNotes
startfloat0.0First value.
stopfloat1.0Last value (included when Endpoint is on).
numint50Number of samples.
endpointbooleantrueWhen on, the last sample is exactly Stop; when off, Stop is excluded.
unittextOptional physical unit for the resulting 1-D Vector.

Description

Linspace is numpy.linspace: exactly Count samples evenly spaced from Start to Stop. Unlike Arange, you control the number of points, not the step, and the endpoint is guaranteed.

When Include endpoint is on, the spacing is and the final sample is pinned to Stop exactly to defeat floating-point drift; when off, the spacing is and Stop is excluded. gives an empty Vector, gives . The output is a Vector that may carry a Unit.

Mathematics

Examples

Unit interval in 5 points

Start = 0, Stop = 1, Count = 5, Endpoint on → , with the last value exactly .

Endpoint excluded

Same start/stop/count with Endpoint off → step , giving (Stop excluded, like an fft bin grid).

Applications

  • A precise time or frequency axis of a known sample count.
  • A parameter sweep with a fixed number of trials between two bounds.
  • Plot abscissae or interpolation grids where the endpoint must land exactly.

Neat

The final sample is overwritten with the exact Stop value after the arithmetic, so floating-point accumulation never leaves the endpoint at 0.9999999 — a detail numpy also guarantees.

Endpoint-off mode divides by num instead of num−1, producing the open grid that fft bin spacing and periodic sampling expect.

Known issues

Count is capped at 100,000,000 samples.

With Count = 1 you always get just [Start], regardless of Stop.

See also

arrayvectorsourcenumpyrangelinspacestateless