uniform#

Signature#

uniform(array_shape, partition_shape, min_value, max_value) → Field#
uniform(array_shape, min_value, max_value) → Field
uniform(other, min_value, max_value) → Field
uniform(min_value, max_value) → Field

Return a field with value(s) drawn from the uniform distribution

Parameters:
  • array_shape (Shape) – Shape of the array

  • partition_shape (Shape) – Shape of the partitions. If not passed in a default partition shape will be used.

  • other (Field) – Array whose shape and partition shape will be used

  • min_value (Field) – Minimum value of the distribution (value, scalar / arithmetic)

  • max_value (Field) – Maximum value of the distribution (value, scalar / arithmetic)

Returns:

New field with value(s) in the range [min_value, max_value] (integral values) or [min_value, max_value) (floating point values) (array, scalar / arithmetic)

Note

Generating random values for uint8 and int8 element types is not supported.

Description#

Operation for creating random fields for various element types, with values in a custom range.

No-data handling#

If min_value or max_value is no-data, no-data is written to the result.

Example#

typedef int32_t Element;
LUE_Rank const rank = 2;
LUE_Count const array_shape[] = {6, 4};

LUE_Field* min_value = NULL;
{
    Element const value = 1;
    LUE_Literal* literal = lue_create_literal(value);

    min_value = lue_as_field(literal);
}

LUE_Field* max_value = NULL;
{
    Element const value = 10;
    LUE_Literal* literal = lue_create_literal(value);

    max_value = lue_as_field(literal);
}

LUE_Field* result = lue_uniform(rank, array_shape, min_value, max_value);

lue_to_gdal(result, result_array_pathname, NULL);

lue_destruct(min_value);
lue_destruct(max_value);
using Element = LargestSignedIntegralElement;

Element const min_value{1};
Element const max_value{10};
Field const result = uniform({6, 4}, min_value, max_value);

to_gdal(result, result_array_pathname);
dtype = lfrx.signed_integral_element_types[-1]
result = lfrx.uniform(
    (6, 4),
    min_value=lfrx.as_field(lfrx.create_literal(1, dtype)),
    max_value=lfrx.as_field(lfrx.create_literal(10, dtype)),
)

lfrx.to_gdal(result, str(result_array_path))

result

result

Source code: C, C++, Python

See also#

Software

Operation name

ArcGIS

UNIFORM

NumPy

random.uniform

PCRaster

mapuniform