tensap.functions.measures package

Submodules

tensap.functions.measures.copulas module

Module copulas.

class tensap.functions.measures.copulas.Copula

Bases: abc.ABC

class tensap.functions.measures.copulas.IndependentCopula

Bases: tensap.functions.measures.copulas.Copula

Methods

cdf

pdf

cdf(u)
pdf(u)

tensap.functions.measures.discrete_measure module

Module discrete_measure.

class tensap.functions.measures.discrete_measure.DiscreteMeasure(values, weights=None)

Bases: tensap.functions.measures.measure.Measure

Class DiscreteMeasure: discrete measure in R^d sum_{i=1}^n w_i delta_{x_i}.

Attributes
valuesnumpy.ndarray

Array containing the set of values (x_1,…,x_N) taken by the random variable, with x_i in R^d, i = 1, …, N.

weightsnumpy.ndarray, optional

Array containing the weights P(X=x_1), …, P(X=x_N). The default is None, indicating to take weights equal to 1.

Methods

integration_rule()

Return the integration rule associated with the measure

mass()

Return the mass of the Measure.

ndim()

Return the dimension of the Measure.

plot(*args)

Plot a graphical representation of the discrete measure.

random([n])

Generate n random numbers according to the probability distribution obtained by rescaling the DiscreteMeasure.

support()

Return the support of the Measure.

integration_rule()

Return the integration rule associated with the measure

Returns
tensap.IntegrationRule

The integration rule associated with the measure

mass()

Return the mass of the Measure.

Returns
None.
ndim()

Return the dimension of the Measure.

Returns
None.
plot(*args)

Plot a graphical representation of the discrete measure.

Parameters
*argstuple

Additional parameters for matplotlib.pyplot’s function vlines.

Returns
None.
random(n=1)

Generate n random numbers according to the probability distribution obtained by rescaling the DiscreteMeasure.

Parameters
nint, optional

The number of random numbers generated. The default is 1.

Returns
numpy.ndarray

The n generated random numbers.

support()

Return the support of the Measure.

Returns
None.

tensap.functions.measures.discrete_random_variable module

Module discrete_random_variable.

class tensap.functions.measures.discrete_random_variable.DiscreteRandomVariable(values, probabilities=None)

Bases: tensap.functions.measures.random_variable.RandomVariable

Class DiscreteRandomVariable.

Attributes
valueslist or numpy.ndarray

Array containing the set of values (x_1,…,x_N) taken by the random variable, with x_i in R^d, i = 1, …, N.

probabilitieslist or numpy.ndarray, optional

Array containing the probabilities P(X=x_1), …, P(X=x_N). The default is None, indicating to create a uniform law: P(X=x_i)=1/N, i = 1, …, N.

Methods

cdf(x)

Compute the cumulative density function of X at x.

cdf_plot(*args)

Plot the cumulative distribution function (cdf) of the random variable.

discretize(n)

Return a discrete random variable taking n possible values x1, …, xn, these values being the quantiles of self of probability 1/(2n) + i/n, i=0n …, n-1 and such that P(Xn >= xn) = 1/n.

gauss_integration_rule(nb_pts)

Return the nb_pts-points gauss integration rule associated with the measure of self, using Golub-Welsch algorithm.

get_parameters()

Return the parameters of the random variable.

get_standard_random_variable()

Return the standard discrete random variable.

icdf(p)

Compute the inverse cumulative density function of X at p (quantile).

icdf_plot(*args)

Plot the inverse cumulative distribution function (icdf) of the random variable.

integration_rule()

Return the integration rule object associated with the discrete random variable.

iso_probabilistic_grid(n)

Return a set of n+1 points (x_0, …, x_{n}) such that the n sets (x0, x_1), [x_1, x_2) .

lhs_random(n[, p])

Latin Hypercube Sampling of the random variable self of n points in dimension p.

likelihood(x)

Compute the log-likelihood of the random variable on sample x.

mass()

Return the mass of the Measure.

max()

Compute the maximum value that can take the inverse cumulative distribution function of the random variable.

mean()

Return the mean of the random variable.

min()

Compute the minimum value that can take the inverse cumulative distribution function of the random variable.

moment(ind[, nargout])

Compute the moments of self of orders contained in ind, defined as E(X^ind[î]).

ndim()

Return the dimension of the random variable, equal to 1.

number_of_parameters()

Compute the number of parameters that admits the random variable.

orthonormal_polynomials(*max_degree)

Return the max_degree-1 first orthonormal polynomials associated with the RandomVariable.

pdf(x)

Compute the probability density function (pdf) of the RandomVariable at points x.

pdf_plot(*args)

Plot the probability density function (pdf) of the random variable.

plot(quantity, *args)

Plot the desired quantity, chosen between ‘pdf’, ‘cdf’ or ‘icdf’.

random([n])

Generate n random numbers according to the distribution of the RandomVariable.

random_variable_statistics()

Return the mean and the variance of the discrete random variable.

std()

Return the standard deviation of the random variable.

support()

Return the support of the Measure.

transfer(Y, x)

Transfer from the random variable self to the random variable Y at points x.

truncated_support()

Return the truncated support of the random variable.

var()

Return the variance of the random variable.

variance()

Return the variance of the random variable.

random_rejection

cdf(x)

Compute the cumulative density function of X at x.

Parameters
xfloat, list or numpy.ndarray

The points at which the cumulative density function of X is to be evaluated.

Returns
numpy.ndarray

The evaluations of the cumulative density function of X at x.

get_parameters()

Return the parameters of the random variable.

get_standard_random_variable()

Return the standard discrete random variable.

Returns
tensap.UniformRandomVariable

The standard discrete random variable.

icdf(p)

Compute the inverse cumulative density function of X at p (quantile).

Parameters
pfloat, list or numpy.ndarray

The points at which the inverse cumulative density function of X is to be evaluated.

Returns
numpy.ndarray

The evaluations of the inverse cumulative density function of X at x.

integration_rule()

Return the integration rule object associated with the discrete random variable.

Returns
tensap.IntegrationRule

The integration rule object associated with the discrete random variable.

mean()

Return the mean of the random variable.

Returns
float

The mean of the random variable.

plot(quantity, *args)

Plot the desired quantity, chosen between ‘pdf’, ‘cdf’ or ‘icdf’.

Parameters
quantitystr

The desired quantity, chosen between ‘pdf’, ‘cdf’ or ‘icdf’.

*argstuple

Additional parameters for matplotlib.pyplot’s function step (for the cdf), vlines (for the pdf) or plot (for the icdf).

Returns
None.
Raises
ValueError

If the provided argument quantity is wrong.

random(n=1)

Generate n random numbers according to the distribution of the RandomVariable.

Parameters
nint

The number of random numbers generated.

Returns
numpy.ndarray

The generated numbers.

random_variable_statistics()

Return the mean and the variance of the discrete random variable.

Returns
float

The mean of the random variable.

float

The variance of the random variable.

support()

Return the support of the Measure.

Returns
None.
var()

Return the variance of the random variable.

Returns
float

The variance of the random variable.

tensap.functions.measures.empirical_random_variable module

Module empirical_random_variable.

class tensap.functions.measures.empirical_random_variable.EmpiricalRandomVariable(sample)

Bases: tensap.functions.measures.random_variable.RandomVariable

Class EmpiricalRandomVariable. A random variable fitted using gaussian kernel smoothing, this class gives best results in the case of normal distributions.

Attributes
samplenumpy.array

The sample used to generate the random variable.

bandwidthfloat

The computed bandwidth for the kernel density estimator.

Methods

cdf(x)

Compute the cumulative distribution function (cdf) of the RandomVariable at points x.

cdf_plot(*args)

Plot the cumulative distribution function (cdf) of the random variable.

discretize(n)

Return a discrete random variable taking n possible values x1, …, xn, these values being the quantiles of self of probability 1/(2n) + i/n, i=0n …, n-1 and such that P(Xn >= xn) = 1/n.

gauss_integration_rule(nb_pts)

Return the nb_pts-points gauss integration rule associated with the measure of self, using Golub-Welsch algorithm.

get_parameters()

Return the parameters of the random variable.

get_standard_random_variable()

Return the standard empirical random variable with zero mean and unit standard deviation.

icdf(x, *args, **kwargs)

Compute the inverse cumulative distribution function (icdf) of the RandomVariable at points x.

icdf_plot(*args)

Plot the inverse cumulative distribution function (icdf) of the random variable.

iso_probabilistic_grid(n)

Return a set of n+1 points (x_0, …, x_{n}) such that the n sets (x0, x_1), [x_1, x_2) .

lhs_random(n[, p])

Latin Hypercube Sampling of the random variable self of n points in dimension p.

likelihood(x)

Compute the log-likelihood of the random variable on sample x.

mass()

Return the mass of the Measure.

max()

Compute the maximum value that can take the inverse cumulative distribution function of the random variable.

mean()

Return the mean of the random variable.

min()

Compute the minimum value that can take the inverse cumulative distribution function of the random variable.

moment(ind[, nargout])

Compute the moments of self of orders contained in ind, defined as E(X^ind[î]).

ndim()

Return the dimension of the random variable, equal to 1.

number_of_parameters()

Compute the number of parameters that admits the random variable.

orthonormal_polynomials(*args)

Return the max_degree-1 first orthonormal polynomials associated with the RandomVariable.

pdf(x)

Compute the probability density function (pdf) of the RandomVariable at points x.

pdf_plot(*args)

Plot the probability density function (pdf) of the random variable.

plot(quantity[, n_pts, bar])

Plot the desired quantity, chosen between ‘pdf’, ‘cdf’ or ‘icdf’.

random([n])

Generate n random numbers according to the distribution of the RandomVariable.

random_variable_statistics()

Return the mean and the variance of the random variable.

shift(b, s)

Shift the random variable using the provided bias and scaling factor.

std()

Return the standard deviation of the random variable.

support()

Return the support of the Measure.

transfer(Y, x)

Transfer from the random variable self to the random variable Y at points x.

truncated_support()

Return the truncated support of the random variable.

variance()

Return the variance of the random variable.

random_rejection

cdf(x)

Compute the cumulative distribution function (cdf) of the RandomVariable at points x.

Parameters
xfloat or list or numpy.ndarray

The points at which the cdf is to be evaluated.

Returns
numpy.ndarray

The evaluations of the cdf at points x.

get_parameters()

Return the parameters of the random variable.

get_standard_random_variable()

Return the standard empirical random variable with zero mean and unit standard deviation.

Returns
tensap.EmpiricalRandomVariable

The standard empirical random variable.

icdf(x, *args, **kwargs)

Compute the inverse cumulative distribution function (icdf) of the RandomVariable at points x.

Parameters
xfloat or list or numpy.ndarray

The points at which the icdf is to be evaluated.

*args, **kwargstuples

Additional parameters for scipy.optimize’s function brentq.

Returns
numpy.ndarray

The evaluations of the icdf at points x.

orthonormal_polynomials(*args)

Return the max_degree-1 first orthonormal polynomials associated with the RandomVariable.

Parameters
max_degreeint, optional

The maximum degree of the returned polynomials. The default is None, choosing the default maximum degree associated with the constructor of the polynomials.

Returns
polytensap.OrthonormalPolynomials

The generated orthonormal polynomials.

pdf(x)

Compute the probability density function (pdf) of the RandomVariable at points x.

Parameters
xfloat or list or numpy.ndarray

The points at which the pdf is to be evaluated.

Returns
numpy.ndarray

The evaluations of the pdf at points x.

random(n=1)

Generate n random numbers according to the distribution of the RandomVariable.

Parameters
nint

The number of random numbers generated.

Returns
numpy.ndarray

The generated numbers.

random_variable_statistics()

Return the mean and the variance of the random variable.

Returns
float

The mean of the random variable.

float

The variance of the random variable.

shift(b, s)

Shift the random variable using the provided bias and scaling factor.

Parameters
biasfloat

The bias.

scalingfloat

The scaling factor.

Returns
tensap.EmpiricalRandomVariable

The shifted random variable.

support()

Return the support of the Measure.

Returns
None.
transfer(Y, x)

Transfer from the random variable self to the random variable Y at points x.

Parameters
Ytensap.RandomVariable

The target RandomVariable of the transfer.

xlist or numpy.ndarray

The input points.

Returns
ynumpy.ndarray

The transfered points.

tensap.functions.measures.measure module

Module measure.

class tensap.functions.measures.measure.Measure

Bases: abc.ABC

Class Measure.

Methods

mass()

Return the mass of the Measure.

ndim()

Return the dimension of the Measure.

support()

Return the support of the Measure.

abstract mass()

Return the mass of the Measure.

Returns
None.
abstract ndim()

Return the dimension of the Measure.

Returns
None.
abstract support()

Return the support of the Measure.

Returns
None.

tensap.functions.measures.normal_random_variable module

Module normal_random_variable.

class tensap.functions.measures.normal_random_variable.NormalRandomVariable(mean=0, standard_deviation=1)

Bases: tensap.functions.measures.random_variable.RandomVariable

Class NormalRandomVariable.

Attributes
momentsnumpy.array

The moments of the normal random variable (if computed).

mufloat, optional

The mean of the normal random variable. The default is 0.

sigmafloat, optional

The standard deviation of the normal random variable. The default is 1.

Methods

cdf(x)

Evaluate the cumulative distribution function (cdf) of the normal random variable at points x.

cdf_plot(*args)

Plot the cumulative distribution function (cdf) of the random variable.

discretize(n)

Return a discrete random variable taking n possible values x1, …, xn, these values being the quantiles of self of probability 1/(2n) + i/n, i=0n …, n-1 and such that P(Xn >= xn) = 1/n.

gauss_integration_rule(nb_pts)

Return the nb_pts-points gauss integration rule associated with the measure of self, using Golub-Welsch algorithm.

get_parameters()

Return the parameters of the normal random variable.

get_standard_random_variable()

Return the standard normal random variable with mean 0 and standard deviation 1.

icdf(x)

Evaluate the inverse cumulative distribution function (icdf) of the normal random variable at points x.

icdf_plot(*args)

Plot the inverse cumulative distribution function (icdf) of the random variable.

iso_probabilistic_grid(n)

Return a set of n+1 points (x_0, …, x_{n}) such that the n sets (x0, x_1), [x_1, x_2) .

lhs_random(n[, p])

Latin Hypercube Sampling of the random variable self of n points in dimension p.

likelihood(x)

Compute the log-likelihood of the random variable on sample x.

mass()

Return the mass of the Measure.

max()

Compute the maximum value that can take the inverse cumulative distribution function of the random variable.

mean()

Return the mean of the random variable.

min()

Compute the minimum value that can take the inverse cumulative distribution function of the random variable.

moment(ind[, nargout])

Compute the moments of self of orders contained in ind, defined as E(X^ind[î]).

ndim()

Return the dimension of the random variable, equal to 1.

number_of_parameters()

Compute the number of parameters that admits the random variable.

orthonormal_polynomials(*max_degree)

Return the max_degree-1 first orthonormal polynomials associated with the NormalRandomVariable.

pdf(x)

Evaluate the probability density function (pdf) of the normal random variable at points x.

pdf_plot(*args)

Plot the probability density function (pdf) of the random variable.

plot(quantity[, n_pts, bar])

Plot the desired quantity, chosen between ‘pdf’, ‘cdf’ or ‘icdf’.

random(n)

Generate n random numbers according to the distribution of the RandomVariable.

random_variable_statistics()

Return the mean and the variance of the random variable.

shift(bias, scaling)

Shift the normal random variable using the provided bias and scaling factor.

std()

Return the standard deviation of the random variable.

support()

Return the support of the normal random variable.

transfer(Y, x)

Transfer from the random variable self to the random variable Y at points x.

truncated_support()

Return the truncated support of the random variable.

variance()

Return the variance of the random variable.

random_rejection

cdf(x)

Evaluate the cumulative distribution function (cdf) of the normal random variable at points x.

Parameters
xlist or numpy.ndarray

The points at which the cdf is to be evaluated.

Returns
numpy.ndarray

The evaluations of the cdf.

get_parameters()

Return the parameters of the normal random variable.

Returns
float

The mean of the random variable.

float

The standard deviation of the random variable.

static get_standard_random_variable()

Return the standard normal random variable with mean 0 and standard deviation 1.

Returns
tensap.NormalRandomVariable

The standard normal random variable.

icdf(x)

Evaluate the inverse cumulative distribution function (icdf) of the normal random variable at points x.

Parameters
xlist or numpy.ndarray

The points at which the icdf is to be evaluated.

Returns
numpy.ndarray

The evaluations of the icdf.

orthonormal_polynomials(*max_degree)

Return the max_degree-1 first orthonormal polynomials associated with the NormalRandomVariable.

Parameters
max_degreeint, optional

The maximum degree of the returned polynomials. The default is None, choosing the default maximum degree associated with the constructor of the polynomials.

Returns
polytensap.OrthonormalPolynomials

The generated orthonormal polynomials.

pdf(x)

Evaluate the probability density function (pdf) of the normal random variable at points x.

Parameters
xlist or numpy.ndarray

The points at which the pdf is to be evaluated.

Returns
numpy.ndarray

The evaluations of the pdf.

random(n)

Generate n random numbers according to the distribution of the RandomVariable.

Parameters
nint

The number of random numbers generated.

Returns
numpy.ndarray

The generated numbers.

random_variable_statistics()

Return the mean and the variance of the random variable.

Returns
float

The mean of the random variable.

float

The variance of the random variable.

shift(bias, scaling)

Shift the normal random variable using the provided bias and scaling factor.

The mean mu of the random variable becomes mu + bias, and its standard deviation sigma becomes sigma * scaling.

Parameters
biasfloat

The bias.

scalingfloat

The scaling factor.

Returns
RVtensap.NormalRandomVariable

The shifted normal random variable.

static support()

Return the support of the normal random variable.

Returns
numpy.ndarray

Support of the normal random variable.

tensap.functions.measures.probability_measure module

Module probability_measure.

class tensap.functions.measures.probability_measure.ProbabilityMeasure

Bases: tensap.functions.measures.measure.Measure

Class ProbabilityMeasure.

Methods

mass()

Return the mass of the Measure.

ndim()

Return the dimension of the Measure.

support()

Return the support of the Measure.

random_rejection

static mass()

Return the mass of the Measure.

Returns
None.
random_rejection(n, Y, c, m)

tensap.functions.measures.product_measure module

Module product_measure.

class tensap.functions.measures.product_measure.ProductMeasure(measures)

Bases: tensap.functions.measures.measure.Measure

Class ProductMeasure.

Attributes
measureslist or tensap.RandomVector

List of Measure objects.

Methods

duplicate(measure, dim)

Create a ProductMeasure by duplicating dim times the provided measure.

mass()

Return the mass of the Measure.

ndim()

Return the dimension of the Measure.

random_vector()

Return, if self is a ProbabilityMeasure, the associated RandomVector.

support()

Return the support of the Measure.

truncated_support()

Return the truncated support of the measures of the ProductMeasure.

marginal

pdf

random

random_sequential

static duplicate(measure, dim)

Create a ProductMeasure by duplicating dim times the provided measure.

Parameters
measuretensap.Measure

The measure to be duplicated.

dimint

The number of times the provided measure is duplicated.

Returns
tensap.ProductMeasure

The created ProductMeasure.

marginal(ind)
mass()

Return the mass of the Measure.

Returns
None.
ndim()

Return the dimension of the Measure.

Returns
None.
pdf(x)
random(x)
random_sequential(x)
random_vector()

Return, if self is a ProbabilityMeasure, the associated RandomVector.

Returns
tensap.RandomVector

The RandomVector associated with self.

support()

Return the support of the Measure.

Returns
None.
truncated_support()

Return the truncated support of the measures of the ProductMeasure.

Returns
list

The truncated support of the measures of the ProductMeasure.

tensap.functions.measures.random_multi_indices module

Module random_multi_indices.

tensap.functions.measures.random_multi_indices.random_multi_indices(shape)

Return a random variable uniformly distributed on I1 x … x Id.

If shape contains integers, the intervals are defined as Ij = np.arange(shape[j-1]), j = 1, …, len(shape).

Parameters
shapelist or numpy.ndarray

The number of elements of each interval, or the interval themselves.

Returns
tensap.RandomVector

The random variable uniformly distributed on I1 x … x Id.

tensap.functions.measures.random_variable module

Module random_variable.

class tensap.functions.measures.random_variable.RandomVariable

Bases: tensap.functions.measures.probability_measure.ProbabilityMeasure

Class RandomVariable.

Attributes
momentsnumpy.array

The moments of the normal random variable (if computed).

Methods

cdf(x)

Compute the cumulative distribution function (cdf) of the RandomVariable at points x.

cdf_plot(*args)

Plot the cumulative distribution function (cdf) of the random variable.

discretize(n)

Return a discrete random variable taking n possible values x1, …, xn, these values being the quantiles of self of probability 1/(2n) + i/n, i=0n …, n-1 and such that P(Xn >= xn) = 1/n.

gauss_integration_rule(nb_pts)

Return the nb_pts-points gauss integration rule associated with the measure of self, using Golub-Welsch algorithm.

get_parameters()

Return the parameters of the random variable.

icdf(x)

Compute the inverse cumulative distribution function (icdf) of the RandomVariable at points x.

icdf_plot(*args)

Plot the inverse cumulative distribution function (icdf) of the random variable.

iso_probabilistic_grid(n)

Return a set of n+1 points (x_0, …, x_{n}) such that the n sets (x0, x_1), [x_1, x_2) .

lhs_random(n[, p])

Latin Hypercube Sampling of the random variable self of n points in dimension p.

likelihood(x)

Compute the log-likelihood of the random variable on sample x.

mass()

Return the mass of the Measure.

max()

Compute the maximum value that can take the inverse cumulative distribution function of the random variable.

mean()

Return the mean of the random variable.

min()

Compute the minimum value that can take the inverse cumulative distribution function of the random variable.

moment(ind[, nargout])

Compute the moments of self of orders contained in ind, defined as E(X^ind[î]).

ndim()

Return the dimension of the random variable, equal to 1.

number_of_parameters()

Compute the number of parameters that admits the random variable.

orthonormal_polynomials(*max_degree)

Return the max_degree-1 first orthonormal polynomials associated with the RandomVariable.

pdf(x)

Compute the probability density function (pdf) of the RandomVariable at points x.

pdf_plot(*args)

Plot the probability density function (pdf) of the random variable.

plot(quantity[, n_pts, bar])

Plot the desired quantity, chosen between ‘pdf’, ‘cdf’ or ‘icdf’.

random(n)

Generate n random numbers according to the distribution of the RandomVariable.

random_variable_statistics()

Return the mean and the variance of the random variable.

std()

Return the standard deviation of the random variable.

support()

Return the support of the Measure.

transfer(Y, x)

Transfer from the random variable self to the random variable Y at points x.

truncated_support()

Return the truncated support of the random variable.

variance()

Return the variance of the random variable.

random_rejection

cdf(x)

Compute the cumulative distribution function (cdf) of the RandomVariable at points x.

Parameters
xfloat or list or numpy.ndarray

The points at which the cdf is to be evaluated.

Returns
numpy.ndarray

The evaluations of the cdf at points x.

cdf_plot(*args)

Plot the cumulative distribution function (cdf) of the random variable.

See also plot.

Parameters
*argstuple

Additional parameters of the method plot.

Returns
None.
discretize(n)

Return a discrete random variable taking n possible values x1, …, xn, these values being the quantiles of self of probability 1/(2n) + i/n, i=0n …, n-1 and such that P(Xn >= xn) = 1/n.

Parameters
nint

The number of possible values the discrete random variable can take.

Returns
tensap.DiscreteRandomVariable

The obtained discrete random variable.

gauss_integration_rule(nb_pts)

Return the nb_pts-points gauss integration rule associated with the measure of self, using Golub-Welsch algorithm.

Parameters
nb_ptsint

The number of integration points.

Returns
tensap.IntegrationRule

The integration rule associated with the measure of self.

get_parameters()

Return the parameters of the random variable.

icdf(x)

Compute the inverse cumulative distribution function (icdf) of the RandomVariable at points x.

Parameters
xfloat or list or numpy.ndarray

The points at which the icdf is to be evaluated.

Returns
numpy.ndarray

The evaluations of the icdf at points x.

icdf_plot(*args)

Plot the inverse cumulative distribution function (icdf) of the random variable.

See also plot.

Parameters
*argstuple

Additional parameters of the method plot.

Returns
None.
iso_probabilistic_grid(n)

Return a set of n+1 points (x_0, …, x_{n}) such that the n sets (x0, x_1), [x_1, x_2) … [x_{n-1}, x_{n}) have all the same probability p = 1/n (with x0 = self.min() and x_{n+1}=self.max()).

Parameters
nint

The number of points of the grid plus one.

Returns
numpy.ndarray

The iso-probabilistic grid.

lhs_random(n, p=1)

Latin Hypercube Sampling of the random variable self of n points in dimension p.

Requires the package pyDOE.

Parameters
nint

Number of points.

pint, optional

The dimension. The default is 1.

Returns
numpy.ndarray

The coordinates of the Latin Hypercube Sampling in each dimension.

likelihood(x)

Compute the log-likelihood of the random variable on sample x.

Parameters
xlist or numpy.ndarray

The sample used to compute the log-likelihood.

Returns
float

The log-likelihood of the random variable on sample x.

max()

Compute the maximum value that can take the inverse cumulative distribution function of the random variable.

Returns
float

The maximum value that can take the inverse cumulative distribution function of the random variable.

mean()

Return the mean of the random variable.

Returns
float

The mean of the random variable.

min()

Compute the minimum value that can take the inverse cumulative distribution function of the random variable.

Returns
float

The minimum value that can take the inverse cumulative distribution function of the random variable.

moment(ind, nargout=1)

Compute the moments of self of orders contained in ind, defined as E(X^ind[î]). If a second output argument is asked, the computed moments are stored in the random variable X.

Parameters
indlist or numpy.ndarray

The orders of the moments.

nargoutint, optional

Indicates the number of expected outputs. The default is 1, indicating to return only the moments.

Returns
numpy.ndarray

The computed moments.

tensap.RandomVariable

The RandomVariable object with the computed moments stored in the attribute moments.

static ndim()

Return the dimension of the random variable, equal to 1.

Returns
int

The dimension of the random variable.

number_of_parameters()

Compute the number of parameters that admits the random variable.

Returns
int

The number of parameters that admits the random variable.

orthonormal_polynomials(*max_degree)

Return the max_degree-1 first orthonormal polynomials associated with the RandomVariable.

Parameters
max_degreeint, optional

The maximum degree of the returned polynomials. The default is None, choosing the default maximum degree associated with the constructor of the polynomials.

Returns
polytensap.OrthonormalPolynomials

The generated orthonormal polynomials.

pdf(x)

Compute the probability density function (pdf) of the RandomVariable at points x.

Parameters
xfloat or list or numpy.ndarray

The points at which the pdf is to be evaluated.

Returns
numpy.ndarray

The evaluations of the pdf at points x.

pdf_plot(*args)

Plot the probability density function (pdf) of the random variable.

See also plot.

Parameters
*argstuple

Additional parameters of the method plot.

Returns
None.
plot(quantity, n_pts=100, bar=False, *args)

Plot the desired quantity, chosen between ‘pdf’, ‘cdf’ or ‘icdf’.

Parameters
quantitystr

The desired quantity, chosen between ‘pdf’, ‘cdf’ or ‘icdf’.

n_ptsint, optional

The number of points used for the plot. The default is 100.

barboolean, optional

Determines if the method uses matplotlib.pyplot’s function bar or plot. The default is False.

*argstuple

Additional parameters for matplotlib.pyplot’s function plot or bar.

Returns
None.
Raises
ValueError

If the provided argument quantity is wrong.

random(n)

Generate n random numbers according to the distribution of the RandomVariable.

Parameters
nint

The number of random numbers generated.

Returns
numpy.ndarray

The generated numbers.

random_variable_statistics()

Return the mean and the variance of the random variable.

Returns
float

The mean of the random variable.

float

The variance of the random variable.

std()

Return the standard deviation of the random variable.

Returns
float

The standard deviation of the random variable.

transfer(Y, x)

Transfer from the random variable self to the random variable Y at points x.

Parameters
Ytensap.RandomVariable

The target RandomVariable of the transfer.

xlist or numpy.ndarray

The input points.

Returns
ynumpy.ndarray

The transfered points.

truncated_support()

Return the truncated support of the random variable.

Returns
supnumpy.ndarray

The truncated support of the random variable.

variance()

Return the variance of the random variable.

Returns
float

The variance of the random variable.

tensap.functions.measures.random_vector module

Module random_vector.

class tensap.functions.measures.random_vector.RandomVector(random_variables, order=None, copula=<tensap.functions.measures.copulas.IndependentCopula object>)

Bases: tensap.functions.measures.probability_measure.ProbabilityMeasure

Class RandomVector.

Attributes
random_variablesnumpy.ndarray

The RandomVariable objects constituting the random vector.

copulatensap.Copula

The copula of the random vector.

Methods

cdf(x)

Compute the cumulative distribution function (cdf) at points x, x must have self.ndim() columns.

get_standard_random_vector()

Return the standard RandomVector associated with self.

iso_probabilistic_grid(n)

Generate a grid of (n[0]-1) x .

lhs_random(n)

Latin Hypercube Sampling of the RandomVector of n points.

mass()

Return the mass of the Measure.

mean()

Return the mean of the random variable.

ndim()

Return the dimension of the Measure.

orthonormal_polynomials([max_degree])

Return the max_degree-1 first orthonormal polynomials associated with the RandomVector.

pdf(x)

Compute the probability density function (pdf) of each RandomVariable in self at points x, x must have self.ndim() columns.

random([n])

Generate n random numbers according to the distribution of the RandomVector.

std()

Return the standard deviation of the random variable.

support()

Return the support of the Measure.

transfer(Y, x)

Transfer from the tensap.RandomVector X to the tensap.RandomVector Y, at points x.

transpose(perm)

Transpose (permute) the components of a random vector.

truncated_support()

Return the truncated support of the random vector.

variance()

Return the variance of the random variable.

marginal

random_rejection

cdf(x)

Compute the cumulative distribution function (cdf) at points x, x must have self.ndim() columns.

Parameters
xlist or numpy.ndarray

The points at which the cdf is to be evaluated.

Returns
numpy.ndarray

The evaluations of the cdf at points x.

get_standard_random_vector()

Return the standard RandomVector associated with self.

Returns
tensap.RandomVector

The standard RandomVector.

iso_probabilistic_grid(n)

Generate a grid of (n[0]-1) x … x (n[d-1]-1) points (x_{i_1}^1, …, x_{i_d}^d) such that the N = (n[0] x … x(n[d-1] sets [x_{i_1-1}^1, x_{i_1}^1] x … x [x_{i_d-1}^1, x_{i_d}^1] have the same probability p = 1/N.

Parameters
nint

The number of points of the grid plus one in each or all the dimensions.

Returns
tensap.FullTensorGrid

The iso-probabilistic grid.

lhs_random(n)

Latin Hypercube Sampling of the RandomVector of n points.

Requires the package pyDOE.

Parameters
nint

Number of points.

Returns
list

List containing the coordinates of the Latin Hypercube Sampling in each dimension.

marginal(ind)
mean()

Return the mean of the random variable.

Returns
float

The mean of the random variable.

ndim()

Return the dimension of the Measure.

Returns
None.
orthonormal_polynomials(max_degree=None)

Return the max_degree-1 first orthonormal polynomials associated with the RandomVector.

Parameters
max_degreeint, optional

The maximum degree of the returned polynomials. The default is None, choosing the default maximum degree associated with the constructor of the polynomials.

Returns
polytensap.OrthonormalPolynomials

The generated orthonormal polynomials.

pdf(x)

Compute the probability density function (pdf) of each RandomVariable in self at points x, x must have self.ndim() columns.

Parameters
xlist or numpy.ndarray

The points at which the pdf is to be evaluated.

Returns
numpy.ndarray

The evaluations of the pdf at points x.

random(n=1)

Generate n random numbers according to the distribution of the RandomVector.

Parameters
nint

The number of random numbers generated.

Returns
numpy.ndarray

The generated numbers.

property size

Return the number of random variables constituting the RandomVector.

Returns
int

The number of random variables constituting the RandomVector.

std()

Return the standard deviation of the random variable.

Returns
float

The standard deviation of the random variable.

support()

Return the support of the Measure.

Returns
None.
transfer(Y, x)

Transfer from the tensap.RandomVector X to the tensap.RandomVector Y, at points x.

Parameters
Ytensap.RandomVector

The target RandomVector of the transfer.

xlist or numpy.ndarray

The input points.

Returns
ynumpy.ndarray

The transfered points.

transpose(perm)

Transpose (permute) the components of a random vector.

Parameters
permlist or numpy.array

The permutation indices.

Returns
tensap.RandomVector

The random vector with transposed (permuted) components.

truncated_support()

Return the truncated support of the random vector.

Returns
supnumpy.ndarray

The truncated support of the random vector.

Raises
NotImplementedError

If the copula is not an IndependentCopula.

variance()

Return the variance of the random variable.

Returns
float

The variance of the random variable.

tensap.functions.measures.uniform_random_variable module

Module uniform_random_variable.

class tensap.functions.measures.uniform_random_variable.UniformRandomVariable(inf=- 1, sup=1)

Bases: tensap.functions.measures.random_variable.RandomVariable

Class UniformRandomVariable.

Attributes
momentsnumpy.array

The moments of the uniform random variable (if computed).

inffloat, optional

The lower bound of the support of the random variable. The default is -1.

supfloat, optional

The upper bound of the support of the random variable. The default is 1.

Methods

cdf(x)

Evaluate the cumulative distribution function (cdf) of the uniform random variable at points x.

cdf_plot(*args)

Plot the cumulative distribution function (cdf) of the random variable.

discretize(n)

Return a discrete random variable taking n possible values x1, …, xn, these values being the quantiles of self of probability 1/(2n) + i/n, i=0n …, n-1 and such that P(Xn >= xn) = 1/n.

gauss_integration_rule(nb_pts)

Return the nb_pts-points gauss integration rule associated with the measure of self, using Golub-Welsch algorithm.

get_parameters()

Return the parameters of the uniform random variable.

get_standard_random_variable()

Return the standard uniform random variable on [-1, 1].

icdf(x)

Evaluate the inverse cumulative distribution function (icdf) of the uniform random variable at points x.

icdf_plot(*args)

Plot the inverse cumulative distribution function (icdf) of the random variable.

iso_probabilistic_grid(n)

Return a set of n+1 points (x_0, …, x_{n}) such that the n sets (x0, x_1), [x_1, x_2) .

lhs_random(n[, p])

Latin Hypercube Sampling of the random variable self of n points in dimension p.

likelihood(x)

Compute the log-likelihood of the random variable on sample x.

mass()

Return the mass of the Measure.

max()

Compute the maximum value that can take the inverse cumulative distribution function of the random variable.

mean()

Return the mean of the random variable.

min()

Compute the minimum value that can take the inverse cumulative distribution function of the random variable.

moment(ind[, nargout])

Compute the moments of self of orders contained in ind, defined as E(X^ind[î]).

ndim()

Return the dimension of the random variable, equal to 1.

number_of_parameters()

Compute the number of parameters that admits the random variable.

orthonormal_polynomials(*max_degree)

Return the max_degree-1 first orthonormal polynomials associated with the UniformRandomVariable.

pdf(x)

Evaluate the probability density function (pdf) of the uniform random variable at points x.

pdf_plot(*args)

Plot the probability density function (pdf) of the random variable.

plot(quantity[, n_pts, bar])

Plot the desired quantity, chosen between ‘pdf’, ‘cdf’ or ‘icdf’.

random([n])

Generate n random numbers according to the distribution of the RandomVariable.

random_variable_statistics()

Return the mean and the variance of the random variable.

shift(bias, scaling)

Shift the uniform random variable using the provided bias and scaling factor.

std()

Return the standard deviation of the random variable.

support()

Return the support of the uniform random variable.

transfer(Y, x)

Transfer from the random variable self to the random variable Y at points x.

truncated_support()

Return the truncated support of the random variable.

variance()

Return the variance of the random variable.

random_rejection

cdf(x)

Evaluate the cumulative distribution function (cdf) of the uniform random variable at points x.

Parameters
xlist or numpy.ndarray

The points at which the cdf is to be evaluated.

Returns
numpy.ndarray

The evaluations of the cdf.

get_parameters()

Return the parameters of the uniform random variable.

Returns
float

The lower bound of the support of the random variable.

float

The upper bound of the support of the random variable.

static get_standard_random_variable()

Return the standard uniform random variable on [-1, 1].

Returns
tensap.UniformRandomVariable

The standard uniform random variable.

icdf(x)

Evaluate the inverse cumulative distribution function (icdf) of the uniform random variable at points x.

Parameters
xlist or numpy.ndarray

The points at which the icdf is to be evaluated.

Returns
numpy.ndarray

The evaluations of the icdf.

orthonormal_polynomials(*max_degree)

Return the max_degree-1 first orthonormal polynomials associated with the UniformRandomVariable.

Parameters
max_degreeint, optional

The maximum degree of the returned polynomials. The default is None, choosing the default maximum degree associated with the constructor of the polynomials.

Returns
polytensap.OrthonormalPolynomials

The generated orthonormal polynomials.

pdf(x)

Evaluate the probability density function (pdf) of the uniform random variable at points x.

Parameters
xlist or numpy.ndarray

The points at which the pdf is to be evaluated.

Returns
numpy.ndarray

The evaluations of the pdf.

random(n=1)

Generate n random numbers according to the distribution of the RandomVariable.

Parameters
nint

The number of random numbers generated.

Returns
numpy.ndarray

The generated numbers.

random_variable_statistics()

Return the mean and the variance of the random variable.

Returns
float

The mean of the random variable.

float

The variance of the random variable.

shift(bias, scaling)

Shift the uniform random variable using the provided bias and scaling factor.

The lower bound inf becomes scaling*inf + bias, and the upper bound sup becomes scaling*sup + bias.

Parameters
biasfloat

The bias.

scalingfloat

The scaling factor.

Returns
shifted_rvtensap.UniformRandomVariable

The shifted uniform random variable.

support()

Return the support of the uniform random variable.

Returns
numpy.ndarray

Support of the uniform random variable.

tensap.functions.measures.uniform_random_variable.rand(d0, d1, ..., dn)

Random values in a given shape.

Note

This is a convenience function for users porting code from Matlab, and wraps random_sample. That function takes a tuple to specify the size of the output, which is consistent with other NumPy functions like numpy.zeros and numpy.ones.

Create an array of the given shape and populate it with random samples from a uniform distribution over [0, 1).

Parameters
d0, d1, …, dnint, optional

The dimensions of the returned array, must be non-negative. If no argument is given a single Python float is returned.

Returns
outndarray, shape (d0, d1, ..., dn)

Random values.

See also

random

Examples

>>> np.random.rand(3,2)
array([[ 0.14022471,  0.96360618],  #random
       [ 0.37601032,  0.25528411],  #random
       [ 0.49313049,  0.94909878]]) #random

Module contents