double truncated data sample
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi,
I generate data x using the code :
clc;
clear;
eta=2;
beta=4;
theta=1;
T=1;
t1=0.1;
t2=0.9;
ni=[10 50 75 100 50];
for i=1:length(ni)
n=ni(i);
for t=1:T
x=generate_sample(n,eta,beta,theta);
f1=pdf_WP(sort(x),eta,beta,theta);
F=cdf_WP(sort(x),eta,beta,theta);
R_Real=1-F;
end
end
the function is:
function [x]=generate_sample(n,eta,beta,theta)
for i=1:n
u=rand;
x(i)=theta.*(1./eta.*(log(1/(1-u)))).^(1./beta);
end
How can I make doule truncate from t1 to t2 from x
with my best regurds
Antworten (1)
Jeff Miller
am 4 Feb. 2021
This is pretty ugly, but I think will do what you asked for:
function [x]=generate_sample(n,eta,beta,theta,t1,t2)
% find the bounds on u corresponding to the desired
% bounds on t1 and t2
xFn = @(u) theta.*(1./eta.*(log(1/(1-u)))).^(1./beta);
u1 = fzero(@(x) xFn(x)-t1,[eps 1-eps]);
u2 = fzero(@(x) xFn(x)-t2,[eps 1-eps]);
for i=1:n
% Generate u's only within the bounds
u=u1 + (u2-u1)*rand;
x(i)=xFn(u);
end
end
2 Kommentare
Jeff Miller
am 8 Feb. 2021
Sorry, I guess I don't understand what you want. Maybe a numerical example would help?
Siehe auch
Kategorien
Mehr zu State-Space Control Design and Estimation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!