How to build an empiric cdf/pdf of a compound poisson continuos distribution
Hi everyone.
as I said in the title i’m trying to obtain the empiric cdf (or pdf) of a compound poisson continuos distribution. Let be a compound poisson distribution with as parameters, while being the parameter of the random variable N (poisson) and F being the distribution of the i-th Y (assuming all are iid and extracted from the same lognormal distribution of given parameters). I managed to build a vector called "x_ptf" which contains random values extracted from , however im struggling into obtaining the empirical cdf/pdf.
clear all; close all; clc
rng(200724)
%mean and standard deviation of a given sample (sample of Yi)
mu_c = 4432.62; var_c= 533130.21;
%lognormal parameters
var_log = log(var_c/mu_c^2+1); sig_log = sqrt(var_log);
mu_log = -var_log/2 +log(mu_c);
%Compound-Poisson distribution
lam = 570; %poisson distribution parameter
nsims = 10^5; %number of simulations
num = poissrnd(lam,1,nsims); %random numbers extracted from the N poisson variable
x_ptf = zeros(nsims,1); %iniziatiling the storage where the random generated numbers will be allocated
for i = 1:length(num)
x_ptf(i) = sum(lognrnd(mu_log,sig_log,1,num(i))); %building randomly generated numbers
end
[cdf, X_ptf] = ecdf(x_con);
X_con = X_con(2:end); cdf = cdf(2:end); %doing this because i get zero two times as the first two components of X_con vector
p = [cdf(1) diff(cdf)’]’; %building the pdf from the cdf
E = sum(X_con.*p); %empirical mean
plot(X_con,p,’*’); %this plot doesn’t make sense
The empirical mean is correct, but the pdf distribution is wrong as shown by the plot. I think it means there’s some problem with the "ecfd" function im using, is there any way to fix? Or maybe some other functions i could try? Ive already used "ksdensity" but it’s not working. Can somebody help?Hi everyone.
as I said in the title i’m trying to obtain the empiric cdf (or pdf) of a compound poisson continuos distribution. Let be a compound poisson distribution with as parameters, while being the parameter of the random variable N (poisson) and F being the distribution of the i-th Y (assuming all are iid and extracted from the same lognormal distribution of given parameters). I managed to build a vector called "x_ptf" which contains random values extracted from , however im struggling into obtaining the empirical cdf/pdf.
clear all; close all; clc
rng(200724)
%mean and standard deviation of a given sample (sample of Yi)
mu_c = 4432.62; var_c= 533130.21;
%lognormal parameters
var_log = log(var_c/mu_c^2+1); sig_log = sqrt(var_log);
mu_log = -var_log/2 +log(mu_c);
%Compound-Poisson distribution
lam = 570; %poisson distribution parameter
nsims = 10^5; %number of simulations
num = poissrnd(lam,1,nsims); %random numbers extracted from the N poisson variable
x_ptf = zeros(nsims,1); %iniziatiling the storage where the random generated numbers will be allocated
for i = 1:length(num)
x_ptf(i) = sum(lognrnd(mu_log,sig_log,1,num(i))); %building randomly generated numbers
end
[cdf, X_ptf] = ecdf(x_con);
X_con = X_con(2:end); cdf = cdf(2:end); %doing this because i get zero two times as the first two components of X_con vector
p = [cdf(1) diff(cdf)’]’; %building the pdf from the cdf
E = sum(X_con.*p); %empirical mean
plot(X_con,p,’*’); %this plot doesn’t make sense
The empirical mean is correct, but the pdf distribution is wrong as shown by the plot. I think it means there’s some problem with the "ecfd" function im using, is there any way to fix? Or maybe some other functions i could try? Ive already used "ksdensity" but it’s not working. Can somebody help? Hi everyone.
as I said in the title i’m trying to obtain the empiric cdf (or pdf) of a compound poisson continuos distribution. Let be a compound poisson distribution with as parameters, while being the parameter of the random variable N (poisson) and F being the distribution of the i-th Y (assuming all are iid and extracted from the same lognormal distribution of given parameters). I managed to build a vector called "x_ptf" which contains random values extracted from , however im struggling into obtaining the empirical cdf/pdf.
clear all; close all; clc
rng(200724)
%mean and standard deviation of a given sample (sample of Yi)
mu_c = 4432.62; var_c= 533130.21;
%lognormal parameters
var_log = log(var_c/mu_c^2+1); sig_log = sqrt(var_log);
mu_log = -var_log/2 +log(mu_c);
%Compound-Poisson distribution
lam = 570; %poisson distribution parameter
nsims = 10^5; %number of simulations
num = poissrnd(lam,1,nsims); %random numbers extracted from the N poisson variable
x_ptf = zeros(nsims,1); %iniziatiling the storage where the random generated numbers will be allocated
for i = 1:length(num)
x_ptf(i) = sum(lognrnd(mu_log,sig_log,1,num(i))); %building randomly generated numbers
end
[cdf, X_ptf] = ecdf(x_con);
X_con = X_con(2:end); cdf = cdf(2:end); %doing this because i get zero two times as the first two components of X_con vector
p = [cdf(1) diff(cdf)’]’; %building the pdf from the cdf
E = sum(X_con.*p); %empirical mean
plot(X_con,p,’*’); %this plot doesn’t make sense
The empirical mean is correct, but the pdf distribution is wrong as shown by the plot. I think it means there’s some problem with the "ecfd" function im using, is there any way to fix? Or maybe some other functions i could try? Ive already used "ksdensity" but it’s not working. Can somebody help? matlab, montecarlo, random number generator, empirical cdf, statistics MATLAB Answers — New Questions