Spice3f5

compose

Compose a vector

General form

compose name values value [value ...]
compose name parm=value [parm=value ...]

Create a new vector called name. It is a more convenient form of let for building sweeps, lists and random data. An existing vector of the same name is replaced, but only once the new one has been made, so a mistake leaves the old one alone.

From a list of values

With values, the vector is made from the rest of the line: each value may be a number or any expression.

compose v values 1 2 5 10

If the values are themselves vectors, the result has one more dimension than they do, with one row per value; shorter vectors are padded with zeros. If any value is complex, the result is complex.

Sweeps

With parameters, the vector is a sweep or a set of random values. Exactly one of lin, log, dec, unif, random and gauss may be given, or else all of start, stop and step, which make a linear sweep. If start is greater than stop, the sweep runs downwards.

start, stop, step
A linear sweep from start to stop in steps of step. If the steps don't fit exactly, the sweep stops at the last whole step.
lin=n
A linear sweep of n points. The end points come from start and stop, or start or stop and step; start defaults to 0 and the step to 1.
log=n
n points spaced logarithmically from start to stop, which must be non-zero and of the same sign.
dec=n
A logarithmic sweep from start towards stop, n points per decade.

Random values

unif=n
n values uniformly distributed between 0 and 1, or between start and stop if both are given.
gauss=n
n normally distributed values with mean mean (default 0) and standard deviation sd (default 1).
random=n
n values picked at random from the vector named by pool, or, with no pool, random whole numbers from start to stop.
seed=s
Start the random number generator from s, so the same values are produced again.

center and span are accepted, but have no effect.

Examples

compose f start=0 stop=1 step=0.25
compose g lin=5 start=10 stop=20
compose h dec=2 start=1 stop=1000
compose r gauss=1000 mean=1 sd=0.05 seed=1
compose pick random=10 pool=g seed=7

make f = 0, 0.25, 0.5, 0.75, 1; g = 10, 12.5, 15, 17.5, 20; h = 1, 3.16, 10, 31.6, 100, 316, 1000; r 1000 values with mean 1 and standard deviation 0.05; and pick 10 values chosen at random from g.

All commands