pub trait RandomIntwhere
Self: Sized,{
type Meta;
// Required methods
fn randint<S: Into<Shape>>(
low: Self::Meta,
high: Self::Meta,
shape: S,
) -> Result<Self, TensorError>
where Self::Meta: SampleUniform,
<Self::Meta as SampleUniform>::Sampler: Sync;
fn randint_like(
&self,
low: Self::Meta,
high: Self::Meta,
) -> Result<Self, TensorError>
where Self::Meta: SampleUniform,
<Self::Meta as SampleUniform>::Sampler: Sync;
}Expand description
A trait for generating random integers.
Required Associated Types§
Required Methods§
Sourcefn randint<S: Into<Shape>>(
low: Self::Meta,
high: Self::Meta,
shape: S,
) -> Result<Self, TensorError>
fn randint<S: Into<Shape>>( low: Self::Meta, high: Self::Meta, shape: S, ) -> Result<Self, TensorError>
Create a Tensor with random integers drawn uniformly from the half-open interval [low, high).
The distribution is uniform, meaning each integer in the range has an equal probability of being drawn.
§Parameters:
low: Lower bound (inclusive) of the range.
high: Upper bound (exclusive) of the range.
shape: Shape of the output tensor.
§Example:
let a = Tensor::<i32>::randint(0, 100, &[10, 10])?;Sourcefn randint_like(
&self,
low: Self::Meta,
high: Self::Meta,
) -> Result<Self, TensorError>
fn randint_like( &self, low: Self::Meta, high: Self::Meta, ) -> Result<Self, TensorError>
Same as randint but the shape will be based on x.
Creates a Tensor with random integers drawn uniformly from the half-open interval [low, high).
§Parameters:
low: Lower bound (inclusive) of the range.
high: Upper bound (exclusive) of the range.
§Example:
let x = Tensor::<i32>::randn(&[10, 10])?;
let r = x.randint_like(0, 100)?; // shape: [10, 10]Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".