# 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, Distribution<T> scalarFitter( 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.
hashCode int
The hash code for this object. [...]
runtimeType Type
A representation of the runtime type of the object.
shape
Shape of the tensor.

## 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}) Tensor<T>
Generates a random sample. [...]
inherited
sampleList(int length, { random}) List<Tensor<T>>
Generates a list of N random samples. [...]
inherited
toString()
A string representation of this object. [...]
inherited

## Operators

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