Table Of Contents

Previous topic

nnet – Ops for neural networks

Next topic

shared_randomstreams – Friendly random numbers

This Page

raw_random – Low-level random numbers

Raw random provides the random-number drawing functionality, that underlies the friendlier RandomStreams interface.

Reference

class raw_random.RandomStreamsBase(object)

This is the interface for the theano.tensor.shared_randomstreams.RandomStreams subclass and the theano.tensor.randomstreams.RandomStreams subclass.

binomial(self, size=(), n=1, prob=0.5, ndim=None):

Sample n times with probability of success prob for each trial, return the number of successes.

If the size argument is ambiguous on the number of dimensions, the first argument may be a plain integer to supplement the missing information.

uniform(self, size=(), low=0.0, high=1.0, ndim=None):

Sample a tensor of given size whose element from a uniform distribution between low and high.

If the size argument is ambiguous on the number of dimensions, the first argument may be a plain integer to supplement the missing information.

normal(self, size=(), avg=0.0, std=1.0, ndim=None):

Usage: normal(random_state, size, Sample from a normal distribution centered on avg with the specified standard deviation (std)

If the size argument is ambiguous on the number of dimensions, the first argument may be a plain integer to supplement the missing information.

random_integers(self, size=(), low=0, high=1, ndim=None):

Usage: random_integers(random_state, size, low=0, high=1) Sample a random integer between low and high, both inclusive.

If the size argument is ambiguous on the number of dimensions, the first argument may be a plain integer to supplement the missing information.

permutation(self, size=(), n=1, ndim=None):

Returns permutations of the integers between 0 and n-1, as many times as required by size. For instance, if size=(p,q), p*q permutations will be generated, and the output shape will be (p,q,n), because each permutation is of size n.

Theano tries to infer the number of dimensions from the length of the size argument, but you may always specify it with the ndim parameter.

Note

Note that the output will then be of dimension ndim+1.

multinomial(self, size=(), n=1, pvals=[0.5, 0.5], ndim=None):

Sample n times from a multinomial distribution defined by probabilities pvals, as many times as required by size. For instance, if size=(p,q), p*q samples will be drawn, and the output shape will be (p,q,len(pvals)).

Theano tries to infer the number of dimensions from the length of the size argument, but you may always specify it with the ndim parameter.

Note

Note that the output will then be of dimension ndim+1.

shuffle_row_elements(self, input):

Return a variable with every row (rightmost index) shuffled.

This uses permutation random variable internally, available via the .permutation attribute of the return value.

class raw_random.RandomStateType(gof.Type)

A Type for variables that will take numpy.random.RandomState values.

raw_random.random_state_type(name=None)

Return a new Variable whose .type is random_state_variable.

class raw_random.RandomFunction(gof.Op)

Op that draws random numbers from a numpy.RandomState object. This Op is parametrized to draw numbers from many possible distributions.

raw_random.uniform(random_state, size=(), low=0.0, high=1.0)

Sample from a uniform distribution between low and high.

If the size argument is ambiguous on the number of dimensions, the first argument may be a plain integer to supplement the missing information.

Returns:RandomVariable, NewRandomState
raw_random.binomial(random_state, size=(), n=1, p=0.5)

Sample n times with probability of success prob for each trial, return the number of successes.

If the size argument is ambiguous on the number of dimensions, the first argument may be a plain integer to supplement the missing information. :returns: RandomVariable, NewRandomState

raw_random.normal(random_state, size=(), avg=0.0, std=1.0)

Sample from a normal distribution centered on avg with the specified standard deviation (std)

If the size argument is ambiguous on the number of dimensions, the first argument may be a plain integer to supplement the missing information.

Returns:RandomVariable, NewRandomState
raw_random.random_integers(random_state, size=(), low=0, high=1)

Sample a random integer between low and high, both inclusive.

If the size argument is ambiguous on the number of dimensions, the first argument may be a plain integer to supplement the missing information.

Returns:RandomVariable, NewRandomState
raw_random.permutation(random_state, size=(), n=1)

Returns permutations of the integers between 0 and n-1, as many times as required by size. For instance, if size=(p,q), p*q permutations will be generated, and the output shape will be (p,q,n), because each permutation is of size n.

If the size argument is ambiguous on the number of dimensions, the first argument may be a plain integer i, which should correspond to len(size). Note that the output will then be of dimension i+1.

Returns:RandomVariable, NewRandomState
raw_random.multinomial(random_state, size=(), p_vals=[0.5, 0.5])

Sample from a multinomial distribution defined by probabilities pvals, as many times as required by size. For instance, if size=(p,q), p*q samples will be drawn, and the output shape will be (p,q,len(pvals)).

If the size argument is ambiguous on the number of dimensions, the first argument may be a plain integer i, which should correspond to len(size). Note that the output will then be of dimension i+1.

Returns:RandomVariable, NewRandomState