double truncated data sample

2 ビュー (過去 30 日間)
Bashar AlHalaq
Bashar AlHalaq 2021 年 2 月 4 日
コメント済み: Walter Roberson 2021 年 2 月 24 日
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

回答 (1 件)

Jeff Miller
Jeff Miller 2021 年 2 月 4 日
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 件のコメント
Bashar AlHalaq
Bashar AlHalaq 2021 年 2 月 8 日
編集済み: Bashar AlHalaq 2021 年 2 月 24 日
thank you for response on my demand ,
but i neeed truncate the sample data range , the code above dont cutting the sample data range
with my best reguard.
Jeff Miller
Jeff Miller 2021 年 2 月 8 日
Sorry, I guess I don't understand what you want. Maybe a numerical example would help?

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

カテゴリ

Help Center および File ExchangeGraphics Objects についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by