Uniform

Contents

Description

This function returns a range with npts number of values. The initial starting value in the range is determined by seed.

The seed can be a value, a data range (e.g. a column), or strings (with "|" or "," or spaces as separators), or a string array. Note that a vector can substitute for the seed.

Note: The seeding algorithm for Origin's methods of random number generation was changed for version 2016. For more information, see documentation for the system variable @ran.

Syntax

//When seed is a value
dataset uniform(int npts[, int seed])

//When seed is strings
dataset uniform(int npts, string seed)

//When seed is a data range
dataset uniform(int npts, dataset seed)

Parameter

npts

the number of values in the returned dataset.

seed or vd

can be a value, a data range (e.g. a column), strings (with "|" or "," or spaces as separators), or a string array. It is used to initialize the returned pseudorandom dataset. According to the different types of seed, we have

Return

Returns a range with npts number of values.

Examples

This example shows use of a value as the seed:

col(A) = uniform(5);//Fill in the first 5 cells in column A with uniformly distributed data.

This example shows use of a data range(column) as seed:

col(B) = uniform(30, col(A));//Randomly choose 30 elements from col(A) to fill col(B)

This example shows use of a string array as seed:

//Create stringarray stra with strings "Origin" and "Lab"
stringarray stra;
stra.Add("Origin");
stra.Add("Lab");

//Use the stra as seed
col(C) = uniform(10, stra);

This example shows how to use a string as seed (three kinds of separators are supported):

col(D) = uniform(10, "Origin|Lab");
col(E) = uniform(10, "Origin,Lab");
col(F) = uniform(10, "Origin Lab");