【问题标题】:Sampling from different distributions using mean and variance of a normal distribution使用正态分布的均值和方差从不同分布中采样
【发布时间】:2013-12-20 20:03:49
【问题描述】:

给定正态分布的均值和方差,我想从任何给定分布中生成随机数。例如:BetaGamma 或 Matlab 中的 Poisson 分布。

如果例如:给我一个数字 0.1,我想围绕它生成随机数。所以我将把这个数字作为我的平均值,预定义的方差为 0.75/1//2。

然后我如何使用这个均值和方差从 matlab 中给我的任何分布中采样?

【问题讨论】:

  • 您是说要将高斯样本转换为(比如)泊松样本,还是要创建(比如)具有相同均值/方差的泊松样本?
  • @Oli:我想创建具有相同均值和方差的 Poisson/beta/gamma 样本。

标签: matlab statistics probability sampling


【解决方案1】:

如果你有统计工具箱:

  • 要生成具有 Beta 分布的随机样本:

    samples = betarnd(a,b,m,n); %// parameters: a, b; sample size m x n
    
  • 要生成具有 Gamma 分布的随机样本:

    samples = gamrnd(a,b,m,n); %// parameters: a, b; sample size m x n
    
  • 要生成具有泊松分布的随机样本:

    samples = poissrnd(l,m,n); %// parameter: l; sample size m x n
    

请注意,这些分布的参数不一定是均值和方差。您将必须计算所需的参数以实现所需的均值和方差。在某些情况下,例如泊松分布,只有一个参数,因此您不能同时指定均值和方差。

对于其他发行版:输入help stats。我的统计工具箱版本包括:

Random Number Generators.
 betarnd     - Beta random numbers.
 binornd     - Binomial random numbers.
 chi2rnd     - Chi square random numbers.
 evrnd       - Extreme value random numbers.
 exprnd      - Exponential random numbers.
 frnd        - F random numbers.
 gamrnd      - Gamma random numbers.
 geornd      - Geometric random numbers.
 gevrnd      - Generalized extreme value random numbers.
 gprnd       - Generalized Pareto inverse random numbers.
 hygernd     - Hypergeometric random numbers.
 iwishrnd    - Inverse Wishart random matrix.
 johnsrnd    - Random numbers from the Johnson system of distributions.
 lognrnd     - Lognormal random numbers.
 mhsample    - Metropolis-Hastings algorithm.
 mnrnd       - Multinomial random vectors.
 mvnrnd      - Multivariate normal random vectors.
 mvtrnd      - Multivariate t random vectors.
 nbinrnd     - Negative binomial random numbers.
 ncfrnd      - Noncentral F random numbers.
 nctrnd      - Noncentral t random numbers.
 ncx2rnd     - Noncentral Chi-square random numbers.
 normrnd     - Normal (Gaussian) random numbers.
 pearsrnd    - Random numbers from the Pearson system of distributions.
 poissrnd    - Poisson random numbers.
 randg       - Gamma random numbers (unit scale).
 random      - Random numbers from specified distribution.
 randsample  - Random sample from finite population.
 raylrnd     - Rayleigh random numbers.
 slicesample - Slice sampling method.
 trnd        - T random numbers.
 unidrnd     - Discrete uniform random numbers.
 unifrnd     - Uniform random numbers.
 wblrnd      - Weibull random numbers.
 wishrnd     - Wishart random matrix.

【讨论】:

  • 对于 beta 和 gamma 分布,我通过应用 en.wikipedia.org/wiki/Beta_distributionen.wikipedia.org/wiki/Gamma_distribution 中给出的方程,使用均值和方差计算了 a 和 b。但是当方差小于1时我遇到了一个问题。在这种情况下,生成的随机数与给定的均值不一致。在那种情况下我该怎么办?
  • 和 poissrnd(l,m,n) 只会生成整数而不是小数。如果我想采样 poissrnd(0.1),这会给我一个 0/​​1。但我想要的是从 0.1 左右开始的随机数。请帮忙!
  • @viggie 泊松房车是离散的!它只能取非负整数!这是基本统计数据!
  • 关于这种情况,当方差小于 1 时?我如何解决该问题以找到适合分布的参数?
  • @viggie 计算参数值,以获得所需的方差。对于泊松情况,是的,一个小的方差意味着大多数样本将是 0 和 1。那又如何呢?
猜你喜欢
  • 1970-01-01
  • 2015-10-23
  • 2014-05-16
  • 2020-06-03
  • 1970-01-01
  • 2014-11-22
  • 2019-01-19
  • 2020-12-18
  • 2019-05-08
相关资源
最近更新 更多