Pseudo Random Nubmer Sampling
Pseudo Random Nubmer Sampling
https://en.wikipedia.org/wiki/Inverse\_transform\_sampling
given a distribution's cumulative distribution function (CDF), generate sample numbers for this distribution.
typically based on uniform distribution variable X (or several of them), then somehow manipulate it, and get random variable Y which has the required distribution
Rejection Sampling if density function is known
one type of Monte-Carlo Method
see some notes
target: sample from F=f(x)
idea: find an alternative G=g(x) which we already know, and that f(x)/g(x) <= c where c is a constant (ideally close to 1)
algorithm:
- sample y from G;
- sample u from U[0,1];
- if u <= f(y)/c*g(y), then accept y; reject otherwise
Inverse Transform Sampling for distributions where CDF is known
- input 1: CDF of some distribution; for example, exponential distribution, F(x)=1-exp{\left(1-\lambda x\right)}
- input 2: a uniform distribution U[0,1]; for example, u=0.387;
- F(x) = y => x = F^{-1}\left(y\right) = -\frac{1}{\lambda}\ln{\left(1-y\right)} => x = -\frac{1}{\lambda}\ln\left(y\right)
- draw a value from U[0,1], and use it as CDF() value, then solve for the corresponding x value
Box-Muller Transform for Normal Distribution
- only used for generating Normal Distribution
- input: uniform distribution U[0,1]
- output: 2 independent standard normal distribution numbers
- Suppose U1 and U2 are independent random variables from U[0,1]
- let
and
, then Z0 and Z1 are both N(0,1) random variables
有一个数组,类似于:{{'Canada', 3}, {'USA', 5}, {'UK', 2}, {'Brasil', 3}}, 数组的类型是Country, 有两个变量, Country.name, Country.weight. 每个国家都有一个权重,然后给一个output()函数,每次调用这个函数的时候就输出一个国家的名字,要使每个国家被输出的概率相等。我用的方法是平摊weight: {Canada, Canada, USA, USA, USA, USA, UK, UK, Brasil, Brasil, Brasil}, 然后用Random 函数输出。Follow up : 如果这个权重的值很大很大,比如billio级别,应该怎么办。我的方法是类似于线段树,然后再用sum * Random(), 看这个区间坐落在哪里。
- target distribution is a discrete distribution, p(x='Canada')=3/13, p(x='USA')=5/13 etc.
- fit it into the Inverse Transform Sampling algorithm
- sample an integer from [1,13], {1,2,3} => Canada, {4,5,6,7,8} => USA, {9,10} => UK, {11,12,13} => Brasil
Pseudo Random Nubmer Sampling的更多相关文章
- ICCV 2017论文分析(文本分析)标题词频分析 这算不算大数据 第一步:数据清洗(删除作者和无用的页码)
IEEE International Conference on Computer Vision, ICCV 2017, Venice, Italy, October 22-29, 2017. IEE ...
- CSharpGL(54)用基于图像的光照(IBL)来计算PBR的Specular部分
CSharpGL(54)用基于图像的光照(IBL)来计算PBR的Specular部分 接下来本系列将通过翻译(https://learnopengl.com)这个网站上关于PBR的内容来学习PBR(P ...
- Python标准库3.4.3-random
9.6. random — Generate pseudo-random numbers Source code: Lib/random.py 翻译:Z.F. This module impleme ...
- 【初学python】使用python调用monkey测试
目前公司主要开发安卓平台的APP,平时测试经常需要使用monkey测试,所以尝试了下用python调用monkey,代码如下: import os apk = {'j': 'com.***.test1 ...
- OFDM学习之旅
前言: 这些日子开始准备搞OFDM之类的,未动先行matlab仿真,这里我会慢慢更新,基本上是自己学习感悟吧<未完待续> 一.PRBS PRBS 是 Pseudo Random Binar ...
- GPS开发之知识储备(NMEA0183)
GPS是英文Global Positioning System(全球定位系统)的简称. NMEA0183(http://files.cnblogs.com/files/libra13179/NMEA0 ...
- 15天玩转redis —— 第五篇 集合对象类型
这篇我们来看看Redis五大类型中的第四大类型:“集合类型”,集合类型还是蛮有意思的,第一个是因为它算是只使用key的Dictionary简易版, 这样说来的话,它就比Dictionary节省很多内存 ...
- Locality Sensitive Hash 局部敏感哈希
Locality Sensitive Hash是一种常见的用于处理高维向量的索引办法.与其它基于Tree的数据结构,诸如KD-Tree.SR-Tree相比,它较好地克服了Curse of Dimens ...
- mod_cluster启用https协议的步骤
1.生成SSL证书与私钥 Generate Private Key on the Server Running Apache + mod_ssl First, generate a private k ...
随机推荐
- HDU 2473 Junk-Mail Filter(并查集的删除操作)
题目地址:pid=2473">HDU 2473 这题曾经碰到过,没做出来. .如今又做了做,还是没做出来. ... 这题涉及到并查集的删除操作.想到了设一个虚节点,可是我把虚节点设为了 ...
- iOS-代理托付的使用
#import "Rigester_ViewController.h" #import "Rigester_ViewController.h" @interfa ...
- 【BZOJ1018】[SHOI2008]堵塞的交通traffic 线段树
[BZOJ1018][SHOI2008]堵塞的交通traffic Description 有一天,由于某种穿越现象作用,你来到了传说中的小人国.小人国的布局非常奇特,整个国家的交通系统可以被看成是一个 ...
- (Android)react-native-splash-screen实践-解决react-native打包好后启动白屏的问题
1.安装 npm i react-native-splash-screen --save or yarn add react-native-splash-screen --save 2.自动配置 re ...
- apache 网页301重定向、自定义400/403/404/500错误页面
首先简单介绍一下,.htaccess文件是Apache服务器中的一个配置文件(Nginx服务器没有),它负责相关目录下的网页配置.通过对.htaccess文件进行设置,可以帮我们实现:网页301重定向 ...
- 转载 j2ee j2se j2me 区别,mvc 和ssh联系理解
[转]J2SE J2EE J2ME的区别 以及 MVC与SSH对应关系 2014-3-6阅读322 评论0 J2SE J2EE J2ME的区别多数编程语言都有预选编译好的类库以支持各种特定的功能,在J ...
- Rocketmq消息持久化
本文编写,参考:https://my.oschina.net/bieber/blog/725646 producer Send()的Message最终将由broker处理,处理类为:SendMessa ...
- 解决使用mybatis做批量操作时发生的异常:Parameter '__frch_item_0' not found. Available parameters are [list] 记录
本文主要描述 使用mybatis进行批量更新.批量插入 过程中遇到的异常及总结: 首先贴出使用批量操作报的异常信息: java.lang.RuntimeException: org.mybatis.s ...
- SpringCloud与Dubbo区别
为什么放弃Dubbo 使用SpringCloud? 相同点:SpringCloud 和Dubbo可以实现RPC远程调用框架,可以实现服务治理. 不同点: SpringCloud是一套目前比较网站微服务 ...
- SpringBoot之外部Tomcat运行Spring Boot项目
内置tomcat8.5.28 外置的要高于此版本才OK spring boot1.5是访问不了jsp页面的 以后要以2.0版本为主流的