Document feedback

Question document fragment

When a question document fragment contains a formula, it is displayed as a space.

Submission type
issue

It's a little complicated...

I'd like to ask someone.

PR

Just a small problem.

I can fix it online!

Please select the submission type

Problem type
Specifications and Common Mistakes

- Specifications and Common Mistakes:

- Misspellings or punctuation mistakes,incorrect formulas, abnormal display.

- Incorrect links, empty cells, or wrong formats.

- Chinese characters in English context.

- Minor inconsistencies between the UI and descriptions.

- Low writing fluency that does not affect understanding.

- Incorrect version numbers, including software package names and version numbers on the UI.

Usability

- Usability:

- Incorrect or missing key steps.

- Missing main function descriptions, keyword explanation, necessary prerequisites, or precautions.

- Ambiguous descriptions, unclear reference, or contradictory context.

- Unclear logic, such as missing classifications, items, and steps.

Correctness

- Correctness:

- Technical principles, function descriptions, supported platforms, parameter types, or exceptions inconsistent with that of software implementation.

- Incorrect schematic or architecture diagrams.

- Incorrect commands or command parameters.

- Incorrect code.

- Commands inconsistent with the functions.

- Wrong screenshots.

- Sample code running error, or running results inconsistent with the expectation.

Risk Warnings

- Risk Warnings:

- Lack of risk warnings for operations that may damage the system or important data.

Content Compliance

- Content Compliance:

- Contents that may violate applicable laws and regulations or geo-cultural context-sensitive words and expressions.

- Copyright infringement.

Please select the type of question

Problem description

Describe the bug so that we can quickly locate the problem.

mindspore.nn.probability.distribution.StudentT

View Source On Gitee
class mindspore.nn.probability.distribution.StudentT(df=None, mean=None, sd=None, seed=None, dtype=mstype.float32, name='StudentT')[source]

StudentT distribution. A StudentT distribution is a continuous distribution with the range (inf,inf) and the probability density function:

f(x,ν,μ,σ)=(1+y2/ν)(0.5(ν+1))/Z

where y=(xμ)/σ, Z=abs(σ)(νπ)Γ(0.5ν)/Γ(0.5(ν+1)), ν,μ,σ are the degrees of freedom , mean and sd of the laplace distribution respectively.

Parameters
  • df (Union[int, float, list, numpy.ndarray, Tensor], optional) – The degrees of freedom. If this arg is None , then the df of the distribution will be passed in runtime. Default: None .

  • mean (Union[int, float, list, numpy.ndarray, Tensor], optional) – The mean of the distribution. If this arg is None , then the df of the distribution will be passed in runtime. Default: None .

  • sd (Union[int, float, list, numpy.ndarray, Tensor], optional) – The standard deviation of the distribution. If this arg is None , then the sd of the distribution will be passed in runtime. Default: None .

  • seed (int, optional) – The seed used in sampling. The global seed is used if it is None. Default: None .

  • dtype (mindspore.dtype, optional) – The type of the event samples. Default: mstype.float32 .

  • name (str, optional) – The name of the distribution. Default: 'StudentT' .

Note

  • df must be greater than zero.

  • sd must be greater than zero.

  • dtype must be a float type because StudentT distributions are continuous.

  • If the arg df, mean or sd is passed in runtime, then it will be used as the parameter value. Otherwise, the value passed in the constructor will be used.

Raises
Supported Platforms:

CPU

Examples

>>> import mindspore
>>> import mindspore.nn as nn
>>> import mindspore.nn.probability.distribution as msd
>>> from mindspore import Tensor
>>> # To initialize a StudentT distribution of the df 2.0, the mean 3.0 and the standard deviation 4.0.
>>> n1 = msd.StudentT(2.0, 3.0, 4.0, dtype=mindspore.float32)
>>> # A StudentT distribution can be initialized without arguments.
>>> # In this case, `df`, `mean` and `sd` must be passed in through arguments.
>>> n2 = msd.StudentT(dtype=mindspore.float32)
>>> # Here are some tensors used below for testing
>>> value = Tensor([1.0, 2.0, 3.0], dtype=mindspore.float32)
>>> df_a = Tensor([2.0], dtype=mindspore.float32)
>>> mean_a = Tensor([2.0], dtype=mindspore.float32)
>>> sd_a = Tensor([2.0, 2.0, 2.0], dtype=mindspore.float32)
>>> df_b = Tensor([1.0], dtype=mindspore.float32)
>>> mean_b = Tensor([1.0], dtype=mindspore.float32)
>>> sd_b = Tensor([1.0, 1.5, 2.0], dtype=mindspore.float32)
>>> ans = n1.log_prob(value)
>>> print(ans.shape)
(3,)
>>> # Evaluate with respect to the distribution b.
>>> ans = n1.log_prob(value, df_b, mean_b, sd_b)
>>> print(ans.shape)
(3,)
>>> # `mean` and `sd` must be passed in during function calls
>>> ans = n2.log_prob(value, df_a, mean_a, sd_a)
>>> print(ans.shape)
(3,)
log_prob(value, df=None, mean=None, sd=None)

Evaluate log probability of the value of the StudentT distribution.

Parameters
  • value (Tensor) - the value to compute.

  • df (Tensor, optional) - the degrees of freedom of the distribution. Default: None .

  • mean (Tensor, optional) - the mean of the distribution. Default: None .

  • sd (Tensor, optional) - the standard deviation of the distribution. Default: None .

Returns

Tensor, the log value of the probability.