Random Laplacian distribution in a specified interval

7 ビュー (過去 30 日間)
Gherbi Nabil
Gherbi Nabil 2021 年 10 月 15 日
コメント済み: Gherbi Nabil 2021 年 10 月 18 日
I try to write a function in matlab that generate a Random Laplacian distribution with output values in the range [0 0.5]; Could anyone suggest me how can I do this ? Thank you.

採用された回答

Jeff Miller
Jeff Miller 2021 年 10 月 15 日
Here is a quick and dirty way to do this with Cupid:
location = 0; % set whatever Laplacian parameters you want.
scale = 1;
lower_limit = 0; % set whatever boundaries you want
upper_limit = 0.5;
trunc_lap = TruncatedX(Laplace(location,scale),lower_limit,upper_limit); % make the truncated distribution
r = trunc_lap.Random(1000,1); % generate a sample of random numbers
histogram(r); % view the random sample
The Laplace pdf and cdf are pretty simple so there is probably a more direct route if you want to work out the math.
  1 件のコメント
Gherbi Nabil
Gherbi Nabil 2021 年 10 月 18 日
Thank you, this is what i searched.

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by