0

我想编写一个代码来生成一个数据集,其中包含 1 个审查数据点和不同的审查百分比。我有以下代码来生成一些随机数但没有被审查

n=input('Enter sample size:');
GM=input('Enter geometric mean:'); 
GSD=input('Enter geometric standard deviation:');
m=input('Enter desired number of dataset:');
x = lognrnd(log(GM), log(GSD),n,m);

我有以下代码来创建一个具有已知检测限 (lod) 值 (LOD) 的审查数据集,然后计算审查值百分比,我有一个数据集可供使用。

c = (x > lod); % c are values less than this number 
x(c) = lod;  % create single lod
sum(c)/length(c) % calculate percent censored

但我想做的是为计算机提供所需的审查百分比,并让计算机找到对应于审查百分比的 lod。我可以手动输入 lod 值,但如果我想创建一个删失百分比为 5-95 的数据集,这需要很长时间。

目标是为模拟创建具有不同删失百分比的删失数据集。我一直在一次做一个数据集,这需要很长时间。请让我知道这一切是否有意义。

4

2 回答 2

1

如果您有统计工具箱,您可以使用函数PRCTILE

pct = 10;
lod = prctile(x, pct);

QUANTILE(它实际上在内部使用 prctile)。

pct = 0.1;
lod = quantile(x,pct);
于 2011-12-03T18:11:31.240 回答
0

肯定有不止一种方法可以解决这个问题,但一种非常直接的方法是使用基于数据的估计 PMF 和 CMF。

如果我想确定一个阈值,使一定百分比的数据低于阈值,我会先这样处理它:

%# Get a histogram of the data
nbins = 100;
[counts xout]=hist(x,nbins);
pmf = counts/length(x);
cmf = cumsum(pmf);

%# Determine the threshold based on some percentage
pct = 0.05;
idx = find(cmf<0.05,1,'last')
thold = xout(idx);

%# in this instance, 5% of the data is below x(idx)
%# now the data can be thresholded
thresholded = x(x>thold);
于 2011-12-03T16:00:03.090 回答