フィルターのクリア

How to generate mixture of exponential and beta distribution

5 ビュー (過去 30 日間)
Lakshit Chugh
Lakshit Chugh 2020 年 5 月 3 日
コメント済み: Jeff Miller 2020 年 5 月 4 日
Hello
I have to generate random variable from exponential and beta distribution where a=4 b=7 for beta and lamda=0.5 while p=0.8 How can i generate mixture of both?

採用された回答

Jeff Miller
Jeff Miller 2020 年 5 月 3 日
Check whether I have interpreted your parameters correctly, but it should look something like this:
lambda = 0.5;
a = 4;
b = 7;
pr_exponen = 0.8;
n = 1000;
e = exprnd(1/lambda,n,1);
b = betarnd(a,b,n,1);
u = rand(n,1);
mix = zeros(n,1);
use_e = u < pr_exponen;
mix(use_e) = e(use_e);
mix(~use_e) = b(~use_e);
figure; histogram(mix);
  4 件のコメント
Lakshit Chugh
Lakshit Chugh 2020 年 5 月 4 日
Ok can you help me i am using the dataset but i am getting mse not valid in the same dataset i am looking to find mse of histogram estimation ?
h = 3.5*s*(length(x)).^(-1/3);
% compute the skew factor (for histograms):
sf = ((2^(1/3))*s) / ( exp(5*s^2/4) * ((s^2 + 2)^(1/3)) * (exp(s^2) - 1)^(1/2) );
h = h*sf;
% get the limits, bins, bin centers etc:
x_lim_left = min(x)-1;
x_lim_rght = max(x)+1;
t0 = x_lim_left;
tm = x_lim_rght;
rng = tm-t0;
nbin = ceil(rng/h);
bins = t0:h:(nbin*h+t0); % <- the bin edges ...
bc = bins(1:end-1)+0.5*h; % <- the bin centers ...
x(find(x<x_lim_left))=x_lim_left;
x(find(x>x_lim_rght))=x_lim_rght;
vk=histc(x,bins); vk(end)=[];
% normalize:
fhat = vk/(n*h);
N_MC = 10;
xinterp = linspace( t0, tm, 15 );
all_mse = zeros(3,length(xinterp),N_MC);
amse = zeros(3,1);
for mci=1:N_MC
%x = exprnd(mu,1,n); % get new data
%x = lognrnd(1,1/2,1,n);
% = std(x);
% the histogram estimate:
[bc,fhat,bins] = norm_ref_rule_w_skew_hist(x);
pdf_approx = interp1(bc,fhat,xinterp,'nearest');
%pdf_approx(pdf_approx>1) = 0.0;
sefx = (pdf_approx - exppdf(xinterp,mu)).^2;
all_mse(1,:,mci) = sefx;
amse(1) = amse(1) + (1/N_MC)*trapz(xinterp,sefx);
Jeff Miller
Jeff Miller 2020 年 5 月 4 日
Sorry, I cannot tell what you are trying to do.

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by