使用正态分布的均值和方差从不同分布中抽样

时间:2013-12-04 11:03:47

标签: matlab statistics probability sampling

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

如果对于例如:我给了一个数字,0.1并且我想在此周围生成随机数。所以我将这个数字作为我的意思,预定方差为0.75 / 1 // 2。

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

1 个答案:

答案 0 :(得分:3)

如果您有统计工具箱:

  • 使用Beta ditribution生成随机样本:

    samples = betarnd(a,b,m,n); %// parameters: a, b; sample size m x n
    
  • 使用Gamma ditribution生成随机样本:

    samples = gamrnd(a,b,m,n); %// parameters: a, b; sample size m x n
    
  • 使用Poisson ditribution生成随机样本:

    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.