Remanding integer from exponential distribution with mean

3 ビュー (過去 30 日間)
HYZ
HYZ 2023 年 1 月 1 日
コメント済み: HYZ 2023 年 1 月 1 日
Hi, I found out exprnd() can generate random number from exponential distribution function with mean. Could anyone suggest how to generate integers instead of numbers from exponential distribution with mean? Thanks!
  2 件のコメント
Walter Roberson
Walter Roberson 2023 年 1 月 1 日
Is the mean integer? Is the random selection required to have exactly that mean or is it statistical? Exactly that mean is equivalent to fixed sum which is the direction DGM took it.
HYZ
HYZ 2023 年 1 月 1 日
The mean is integer. The random selection isn't statistical.

サインインしてコメントする。

採用された回答

DGM
DGM 2023 年 1 月 1 日
編集済み: DGM 2023 年 1 月 1 日
If I recall, there are other ways to do this.
MIMT has a tool for generating random integers with sum and range constraints. The above example is more memory-intensive than the method used in randisum().
N = 1000; % number of values to generate
av = 20; % mean of all values
R = randisum([0 NaN],av*N,[N 1],'exponential');
histogram(R,'binmethod','integers')
mean(R) % the mean is as specified
ans = 20
nnz(mod(R,1)) % all values are integers
ans = 0
Note that the constraint here is actually the sum, not the mean. While av can be a non-integer, the value av*N must be an integer. This also means that (unlike exprnd()), av is the sample mean, not the mean of the distribution. I don't know if that's sufficient for your needs.

その他の回答 (0 件)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by