【问题标题】:Matlab Bootstrap not complete resamplingMatlab Bootstrap没有完成重采样
【发布时间】:2014-01-09 15:43:54
【问题描述】:

我想在 Matlab 中执行引导程序。我有 100 个原始数据点,我希望引导程序的每次迭代仅随机选择 57 个替换点。如何实现?

我似乎在 Matlab 函数 bootstrp 中找不到此功能。

问候,

【问题讨论】:

    标签: matlab statistics-bootstrap


    【解决方案1】:

    要从带有替换的向量中随机选择n 点:使用randi 生成(可能重复的)索引:

    vector = (1:100).^2; %// example data
    n = 57;
    ind = randi(numel(vector),1,n); %// n random integers between 1 and numel(vector)
    sample = vector(ind);
    

    直接使用bootstrp:让fun 表示您将传递给bootstrp 的函数。您只需选择每个 100 值样本的前 57 个值:

    vector = (1:100).^2; %// example data
    n = 57;
    nboot = 10;
    bootstrp(nboot, @(x) fun(x(1:57)), vector)
    

    【讨论】:

    • 谢谢你,路易斯!我还发现了允许用替换重新采样的函数(randsample,datasample)。太糟糕的功能没有内置到 bootstrp 中。
    • @user1700890 我从未使用过bootstrp,但它似乎可以做到,只要您在传递的函数中合并每个样本的值的减少(从 100 到 57)到bootstrp。例如,尝试bootstrp(3,@(x) x(1:5), 1:10)。这给了我 3 行,每行 5 个元素,从1:10 重复采样。查看编辑后的答案
    猜你喜欢
    • 2012-11-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-26
    • 2017-02-23
    • 1970-01-01
    相关资源
    最近更新 更多