---
title: "ClikaRT::ops::rand"
sidebar_label: "rand"
description: "Uniform random tensor on [0, 1). shape the output shape (each extent a scalar or 0-D tensor). dtype output float dtype; default Float32."
---

<!-- Generated by tools/doxygen2mdx from Doxygen XML. Do not edit. -->

<span class="api-kind api-kind--function">function</span>

## rand() {#rand}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`rand`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`ClikaRT::Span`](../Span.md)`<const` [`ScalarOrTensor`](../ScalarOrTensor.md)`>` `shape`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`DataType`](../../index.md#DataType) `dtype` `=` [`DataType::Float32`](../../index.md#DataType),<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`StreamOrDevice`](../StreamOrDevice.md) `device` `=` `{}`<br />
)

</div>

Uniform random tensor on `[0, 1)`.

**Parameters**

- `shape`: the output shape (each extent a scalar or 0-D tensor).
- `dtype`: output float dtype; default `Float32`.
- `device`: stream or device to allocate/run on; default = the default device.

**Returns:** a [`shape`](./shape.md#shape)-shaped tensor of uniform draws.

**Throws**

- `ClikaRT::Error`: (`INVALID_ARGUMENT`) on a non-float [`dtype`](../dtype/index.md).

<div class="api-declared">

Declared in `ClikaRT/compute/ops.h`, line 4186

</div>
