matlab - 一定区间内服从指数分布的随机数

标签 matlab math probability

<分区>

我想使用指数分布在特定区间内生成一个随机数。我的问题是,如果我使用 exprnd 我无法控制间隔,我只能给出一个平均值,但这不符合我的需要。 是否有其他功能或我必须使用的一些技巧?

最佳答案

这有帮助吗? (或者我误解了这个问题?)

%#Set the parameters
T = 2000; %#Number of observations to simulate
Mu = 0.5; %#Exponential distribution parameter
LB = 0; %#Lower bound on exponential distribution
UB = 1; %#Upper bound on exponential distribution

%#Validate the parameters
if LB < 0 || UB < 0; error('Bounds must be non-negative'); end
if Mu <= 0; error('Mu must be positive'); end

%#Determine LB and UB in terms of cumulative probabilities
LBProb = expcdf(LB, Mu);
UBProb = expcdf(UB, Mu);

%#Simulate uniform draws from the interval LBProb to UBProb
Draw = LBProb + (UBProb - LBProb) .* rand(T, 1);

%#Convert the uniform draws to exponential draws using the inverse cdf
X = expinv(Draw, Mu);

关于matlab - 一定区间内服从指数分布的随机数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13218100/

相关文章:

math - GPS 'Submarine' 雷达检测其他位置

python - Sympy 不会评估 2x 但会评估 x*2

python-3.x - 鉴于我有python中指定的各种范围的概率,我如何生成随机数

R:计算至少抽到 1 个红色弹珠的概率

matlab - 如何从 wav 文件制作频谱图

algorithm - 多边形算法解释中的点

matlab - 表格单元格只能通过双击进行编辑

matlab - 将双峰正态分布拟合到值向量,而不是其直方图

python - 数学表达式作为函数的参数?

machine-learning - 使用伪随机数生成器与马尔可夫链蒙特卡罗中的真实随机数不同吗?