Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
4c7389b0
提交
4c7389b0
authored
8月 02, 2022
作者:
Rémi Louf
提交者:
Brandon T. Willard
8月 04, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add docstrings for RVs related to normal distribution
上级
d2f139e6
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
129 行增加
和
0 行删除
+129
-0
basic.py
aesara/tensor/random/basic.py
+117
-0
basic.rst
doc/library/tensor/random/basic.rst
+12
-0
没有找到文件。
aesara/tensor/random/basic.py
浏览文件 @
4c7389b0
...
@@ -106,6 +106,18 @@ beta = BetaRV()
...
@@ -106,6 +106,18 @@ beta = BetaRV()
class
NormalRV
(
RandomVariable
):
class
NormalRV
(
RandomVariable
):
r"""A normal continuous random variable.
The probability density function for `normal` in terms of its location parameter (mean)
:math:`\mu` and scale parameter (standard deviation) :math:`\sigma` is:
.. math::
f(x; \mu, \sigma) = \frac{1}{\sqrt{2 \pi \sigma^2}} e^{-\frac{(x-\mu)^2}{2\sigma^2}}
for :math:`\sigma > 0`.
"""
name
=
"normal"
name
=
"normal"
ndim_supp
=
0
ndim_supp
=
0
ndims_params
=
[
0
,
0
]
ndims_params
=
[
0
,
0
]
...
@@ -113,6 +125,21 @@ class NormalRV(RandomVariable):
...
@@ -113,6 +125,21 @@ class NormalRV(RandomVariable):
_print_name
=
(
"N"
,
"
\\
operatorname{N}"
)
_print_name
=
(
"N"
,
"
\\
operatorname{N}"
)
def
__call__
(
self
,
loc
=
0.0
,
scale
=
1.0
,
size
=
None
,
**
kwargs
):
def
__call__
(
self
,
loc
=
0.0
,
scale
=
1.0
,
size
=
None
,
**
kwargs
):
r"""Draw samples from a normal distribution.
Parameters
----------
loc
Mean :math:`\mu` of the normal distribution.
scale
Standard deviation :math:`\sigma` of the normal distribution. Must be positive.
size
Sample shape. If the given size is, e.g. `(m, n, k)` then `m * n * k`
independent, identically distributed random variables are
returned. Default is `None` in which case a single random variable
is returned.
"""
return
super
()
.
__call__
(
loc
,
scale
,
size
=
size
,
**
kwargs
)
return
super
()
.
__call__
(
loc
,
scale
,
size
=
size
,
**
kwargs
)
...
@@ -120,7 +147,28 @@ normal = NormalRV()
...
@@ -120,7 +147,28 @@ normal = NormalRV()
class
StandardNormalRV
(
NormalRV
):
class
StandardNormalRV
(
NormalRV
):
r"""A standard normal continuous random variable.
The probability density function for `standard_normal` is:
.. math::
f(x) = \frac{1}{\sqrt{2 \pi}} e^{-\frac{x^2}{2}}
"""
def
__call__
(
self
,
size
=
None
,
**
kwargs
):
def
__call__
(
self
,
size
=
None
,
**
kwargs
):
"""Draw samples from a standard normal distribution.
Parameters
----------
size
Sample shape. If the given size is, e.g. `(m, n, k)` then `m * n * k`
independent, identically distributed random variables are
returned. Default is `None` in which case a single random variable
is returned.
"""
return
super
()
.
__call__
(
loc
=
0.0
,
scale
=
1.0
,
size
=
size
,
**
kwargs
)
return
super
()
.
__call__
(
loc
=
0.0
,
scale
=
1.0
,
size
=
size
,
**
kwargs
)
...
@@ -128,6 +176,18 @@ standard_normal = StandardNormalRV()
...
@@ -128,6 +176,18 @@ standard_normal = StandardNormalRV()
class
HalfNormalRV
(
ScipyRandomVariable
):
class
HalfNormalRV
(
ScipyRandomVariable
):
r"""A half-normal continuous random variable.
The probability density function for `halfnormal` in terms of its location parameter
:math:`\mu` and scale parameter :math:`\sigma` is:
.. math::
f(x; \mu, \sigma) = \frac{1}{\sqrt{2 \pi \sigma^2}} e^{-\frac{(x-\mu)^2}{2\sigma^2}}
for :math:`x \geq 0` and :math:`\sigma > 0`.
"""
name
=
"halfnormal"
name
=
"halfnormal"
ndim_supp
=
0
ndim_supp
=
0
ndims_params
=
[
0
,
0
]
ndims_params
=
[
0
,
0
]
...
@@ -135,10 +195,40 @@ class HalfNormalRV(ScipyRandomVariable):
...
@@ -135,10 +195,40 @@ class HalfNormalRV(ScipyRandomVariable):
_print_name
=
(
"N**+"
,
"
\\
operatorname{N^{+}}"
)
_print_name
=
(
"N**+"
,
"
\\
operatorname{N^{+}}"
)
def
__call__
(
self
,
loc
=
0.0
,
scale
=
1.0
,
size
=
None
,
**
kwargs
):
def
__call__
(
self
,
loc
=
0.0
,
scale
=
1.0
,
size
=
None
,
**
kwargs
):
r"""Draw samples from a half-normal distribution.
Parameters
----------
loc
Location parameter :math:`\mu` of the distribution.
scale
Scale parameter :math:`\sigma` of the distribution.
size
Sample shape. If the given size is, e.g. `(m, n, k)` then `m * n * k`
independent, identically distributed random variables are
returned. Default is `None` in which case a single random variable
is returned.
"""
return
super
()
.
__call__
(
loc
,
scale
,
size
=
size
,
**
kwargs
)
return
super
()
.
__call__
(
loc
,
scale
,
size
=
size
,
**
kwargs
)
@classmethod
@classmethod
def
rng_fn_scipy
(
cls
,
rng
,
loc
,
scale
,
size
):
def
rng_fn_scipy
(
cls
,
rng
,
loc
,
scale
,
size
):
r"""Draw sample from a half-normal distribution using Scipy's generator.
Parameters
----------
loc
Location parameter :math:`\mu` of the distribution.
scale
Scale parameter :math:`\sigma` of the distribution.
size
Sample shape. If the given size is, e.g. `(m, n, k)` then `m * n * k`
independent, identically distributed random variables are
returned. Default is `None` in which case a single random variable
is returned.
"""
return
stats
.
halfnorm
.
rvs
(
loc
,
scale
,
random_state
=
rng
,
size
=
size
)
return
stats
.
halfnorm
.
rvs
(
loc
,
scale
,
random_state
=
rng
,
size
=
size
)
...
@@ -146,6 +236,18 @@ halfnormal = HalfNormalRV()
...
@@ -146,6 +236,18 @@ halfnormal = HalfNormalRV()
class
LogNormalRV
(
RandomVariable
):
class
LogNormalRV
(
RandomVariable
):
r"""A lognormal continuous random variable.
The probability density function for `lognormal` in terms of the mean
parameter :math:`\mu` and sigma parameter :math:`\sigma` is:
.. math::
f(x; \mu, \sigma) = \frac{1}{x \sqrt{2 \pi \sigma^2}} e^{-\frac{(\ln(x)-\mu)^2}{2\sigma^2}}
for :math:`x > 0` and :math:`\sigma > 0`.
"""
name
=
"lognormal"
name
=
"lognormal"
ndim_supp
=
0
ndim_supp
=
0
ndims_params
=
[
0
,
0
]
ndims_params
=
[
0
,
0
]
...
@@ -153,6 +255,21 @@ class LogNormalRV(RandomVariable):
...
@@ -153,6 +255,21 @@ class LogNormalRV(RandomVariable):
_print_name
=
(
"LogN"
,
"
\\
operatorname{LogN}"
)
_print_name
=
(
"LogN"
,
"
\\
operatorname{LogN}"
)
def
__call__
(
self
,
mean
=
0.0
,
sigma
=
1.0
,
size
=
None
,
**
kwargs
):
def
__call__
(
self
,
mean
=
0.0
,
sigma
=
1.0
,
size
=
None
,
**
kwargs
):
r"""Draw sample from a lognormal distribution.
Parameters
----------
mean
Mean :math:`\mu` of the random variable's natural logarithm.
sigma
Standard deviation :math:`\sigma` of the random variable's natural logarithm.
size
Sample shape. If the given size is, e.g. `(m, n, k)` then `m * n * k`
independent, identically distributed random variables are
returned. Default is `None` in which case a single random variable
is returned.
"""
return
super
()
.
__call__
(
mean
,
sigma
,
size
=
size
,
**
kwargs
)
return
super
()
.
__call__
(
mean
,
sigma
,
size
=
size
,
**
kwargs
)
...
...
doc/library/tensor/random/basic.rst
浏览文件 @
4c7389b0
...
@@ -51,3 +51,15 @@ Aesara can produce :class:`RandomVariable`\s that draw samples from many differe
...
@@ -51,3 +51,15 @@ Aesara can produce :class:`RandomVariable`\s that draw samples from many differe
.. autoclass:: aesara.tensor.random.basic.GammaRV
.. autoclass:: aesara.tensor.random.basic.GammaRV
:members: __call__
:members: __call__
.. autoclass:: aesara.tensor.random.basic.NormalRV
:members: __call__
.. autoclass:: aesara.tensor.random.basic.StandardNormalRV
:members: __call__
.. autoclass:: aesara.tensor.random.basic.HalfNormalRV
:members: __call__
.. autoclass:: aesara.tensor.random.basic.LogNormalRV
:members: __call__
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论