Gumbel distribution
概
感觉这个分布的含义很有用啊, 能预测‘最大', 也就是自然灾害, 太牛了.
主要内容
定义
[Gumbel distribution-wiki](Gumbel distribution - Wikipedia)
其分布函数和概率密度函数分别为:
\]
标准Gumbel分布(即\(\mu=0, \beta=1\)):
\]
从Gumbel分布中采样, 只需:
\]
proof:
\]
故\(F^{-1}(u)\)的分布函数就是\(F(x)\).
\]
其中 \(\gamma\)是Euler-Mascherorni constant.
Gumbel-Max trick
假设我们有一个离散的分布\([\pi_1, \pi_2, \cdots, \pi_k]\)共\(k\)类, \(\pi_i\)表示为第\(i\)类的概率, 则从该分布中采样\(z\)等价于
\]
proof:
\]
又
\]
带入计算得:
P(z=i)
& = \int_{-\infty}^{+\infty} e^{-(x+e^{-x} \cdot \frac{1}{\pi_i})} \mathrm{d}x \\
& = \int_{-\infty}^{+\infty} \pi_i \cdot e^{-[(x-\log\frac{1}{\pi_i})+e^{-(x - \log \frac{1}{\pi_i})}]} \mathrm{d}x \\
& = \pi_i.
\end{array}
\]
Gumbel trick 用于归一化
我们时常会碰到这样的问题:
\]
其中\(Z=\sum_{i=1}^K f(x_i;\theta)\) 是归一化常数, 那么怎么计算\(Z\)呢?
构建随机变量\(T\):
\]
则
\]
proof:
\]
因为
\]
故我们只需估计\(\mathbb{E}[T] \approx \sum_j T_j\) 即可估计\(Z\)
\]
所以必须要求离散的\(x\)?
代码
[scipy-gumbel](scipy.stats.gumbel_r — SciPy v1.6.3 Reference Guide)
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import gumbel_r
fig, ax = plt.subplots(1, 1)
# mean, var, skew, kurt = gumbel_r.stats(moments='mvsk')
# print(mean, var, skew, kurt)
x = np.linspace(gumbel_r.ppf(0.01), gumbel_r.ppf(0.99), 100)
ax.plot(x, gumbel_r.pdf(x), 'r-', lw=5, alpha=0.6, label="gumbel_r pdf")
r = gumbel_r.rvs(size=1000, loc=0, scale=1)
ax.hist(r, density=True, histtype="stepfilled", alpha=0.2)
ax.legend(loc='best', frameon=False)
plt.show()

Gumbel distribution的更多相关文章
- Gumbel-Softmax Trick和Gumbel分布
之前看MADDPG论文的时候,作者提到在离散的信息交流环境中,使用了Gumbel-Softmax estimator.于是去搜了一下,发现该技巧应用甚广,如深度学习中的各种GAN.强化学习中的A2 ...
- (数据科学学习手札03)Python与R在随机数生成上的异同
随机数的使用是很多算法的关键步骤,例如蒙特卡洛法.遗传算法中的轮盘赌法的过程,因此对于任意一种语言,掌握其各类型随机数生成的方法至关重要,Python与R在随机数底层生成上都依靠梅森旋转(twiste ...
- Python中生成随机数
目录 1. random模块 1.1 设置随机种子 1.2 random模块中的方法 1.3 使用:生成整形随机数 1.3 使用:生成序列随机数 1.4 使用:生成随机实值分布 2. numpy.ra ...
- Categorical Reparameterization with Gumbel-Softmax
目录 概 主要内容 Gumbel distribution Jang E., Gu S. and Poole B. Categorical reparameterization with gumbel ...
- 齐夫定律, Zipf's law,Zipfian distribution
齐夫定律(英语:Zipf's law,IPA英语发音:/ˈzɪf/)是由哈佛大学的语言学家乔治·金斯利·齐夫(George Kingsley Zipf)于1949年发表的实验定律. 它可以表述为: 在 ...
- CloudSim4.0报错NoClassDefFoundError,Caused by: java.lang.ClassNotFoundException: org.apache.commons.math3.distribution.UniformRealDistribution
今天下载了CloudSim 4.0的代码,运行其中自带的示例程序,结果有一部分运行错误: 原因是找不到org.apache.commons.math3.distribution.UniformReal ...
- Wishart distribution
Introduction In statistics, the Wishart distribution is generalization to multiple dimensions of the ...
- distribution 中一直在运行 waitfor delay @strdelaytime 语句
Replication 自动创建来一个 Job:Replication monitoring refresher for distribution,这个Agent执行一个sp: dbo.sp_repl ...
- Distribution2:Distribution Writer
Distribution Writer 调用Statement Delivery 存储过程,将Publication的改变同步到Subscriber中.查看Publication Properties ...
随机推荐
- 备忘录:关于.net程序连接Oracle数据库
目录 关于使用MSSM访问Oracle数据库 关于. net 程序中连接Oracle数据库 志铭-2021年12月7日 21:22:15 关于使用MSSM访问Oracle数据库 安装访问接口组件:Or ...
- day14搭建博客系统项目
day14搭建博客系统项目 1.下载代码包 [root@web02 opt]# git clone https://gitee.com/lylinux/DjangoBlog.git 2.使用pid安装 ...
- 什么是 IP 地址 – 定义和解释
IP 地址定义 IP 地址是一个唯一地址,用于标识互联网或本地网络上的设备.IP 代表"互联网协议",它是控制通过互联网或本地网络发送的数据格式的一组规则. 本质上,IP 地址是允 ...
- 【leetcode】170. Two Sum III - Data structure design 两数之和之三 - 数据结构设计
Design and implement a TwoSum class. It should support the following operations: add and find. add ...
- JavaIO——内存操作流、打印流
我们之前所做的都是对文件进行IO处理,实则我们也可以对内存进行IO处理.我们将发生在内存中的IO处理称为内存流. 内存操作流也可分为两类:字节内存流和字符内存流. (1)ByteArrayInputS ...
- How does “void *” differ in C and C++?
C allows a void* pointer to be assigned to any pointer type without a cast, whereas C++ does not; th ...
- 【编程思想】【设计模式】【行为模式Behavioral】状态模式State
Python版 https://github.com/faif/python-patterns/blob/master/behavioral/state.py #!/usr/bin/env pytho ...
- Nginx 1.9.7.2 + PHP 5.6.18(FastCGI)在CentOS Linux下的编译安装
本文参考张宴的Nginx 0.8.x + PHP 5.2.13(FastCGI)搭建胜过Apache十倍的Web服务器(第6版)[原创]完成.所有操作命令都在CentOS 6.x 64位操作系统下实践 ...
- List如何一边遍历,一边删除?
1.新手常犯的错误 可能很多新手(包括当年的我,哈哈)第一时间想到的写法是下面这样的: public static void main(String[] args) { List<String& ...
- JS中操作JSON总结
JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式,采用完全独立于语言的文本格式,是理想的数据交换格式.同时,JSON是 JavaScript 原生格式,这意 ...