TensorDistribution<T> class Null safety

A distribution that samples tensor element values from independent distributions.

Example

import 'package:calc/calc.dart';

void main() {
  // Construct a distribution for matrices 2 rows and 3 columns.
  // Each element is sampled from unit normal distribution.
  const distribution = TensorDistribution.filled(
    TensorShape([2,3]),
    NormalDistribution(mean: 0.0, variance:1.0),
  );

  // Sample the distribution.
  final tensor = distribution.sample();
}
Inheritance

Constructors

TensorDistribution.filled(TensorShape shape, Distribution<T> distribution)
Constructing a distribution where all indices have identical scalar distribution.
factory
TensorDistribution.fitScalarsIndependently(Iterable<Tensor<double>> iterable, Distribution<T> scalarFitter(Iterable<double> iterable))
Constructs a distribution by fitting a distribution to each index independently.
factory
TensorDistribution.generate(TensorShape shape, Distribution<T> generator(TensorShape shape, int index))
Generates distribution for each index independently.
factory

Properties

distributions List<Distribution<T>>
Distribution for each (flat) index of the tensor.
read-only
hashCode int
The hash code for this object. [...]
read-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
shape TensorShape
Shape of the tensor.
read-only

Methods

map<R>(R f(Tensor<T> value)) Distribution<R>
Maps samples of the distribution with the given function. [...]
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
sample({Random? random}) Tensor<T>
Generates a random sample. [...]
inherited
sampleList(int length, {Random? random}) List<Tensor<T>>
Generates a list of N random samples. [...]
inherited
toString() String
A string representation of this object. [...]
inherited

Operators

operator ==(Object other) bool
The equality operator. [...]
inherited