2

私は水文時系列データを使用しており、Bootstrap ArtificialNeuralNetworkモデルを構築しようとしています。信頼区間を使用して不確実性評価を提供するには、元の時系列データセットをリサンプリング/ブートストラップするときに、分散を計算するために、元の時系列のすべての値がすべてのブートストラップサンプル内で少なくとも2回抑制されていることを確認する必要がありますその時点での信頼区間。

いくつかの背景を与えるために:

月ごとの時間ステップで標準降水指数値を含む水文時系列を使用しています。この時系列は429(行)x 1(列)にまたがっています。この時系列ベクトルと呼びましょうX。のすべての要素/値は、Xとの間で正規化および標準化され01います。

次に、時系列Xがニューラルネットワークのいくつかのターゲット値(と同じ長さと条件X)に対してトレーニングされ、ターゲット値の新しい推定値が生成されます。この出力ベクトルをO(と同じ長さと条件X)と呼びます。

私は今、それを何度も取得Xしてリサンプリングしii =1:1:200(つまり、ブートストラップサイズ= 200)、長さ(429)を置き換えます。すべてのブートストラップサンプルが配置されている行列を呼び出しましょうM。を使用B = randsample(X, length(X), true)M、forループを使用して入力しますM(:,ii) = B。注:よりランダムな結果が得られることを期待して、RNGを新しい状態に移行し続けるためrng('shuffle')に、ステートメントの後に必ず含めるようにします。randsample

次に、信頼区間の作成に使用するためにデータがどの程度「適切に」リサンプリングされたかをテストします。

私の手順は次のとおりです。

  1. 上記の手順を使用してMを作成するためのforループを生成します
  2. 新しい変数を作成します。これにより、ブートストラップサンプルでリサンプリングされなかったXcすべての値が保持されます。Xii for ii = 1:1:200
  3. For j=1:1:length(X) fill 'Xc' using the Xc(j,ii) = setdiff(X, M(:,ii))、要素jが。でM(:,ii)埋めXc(j,ii)られている場合NaN
  4. Xcは、と同じサイズと次元の行列になりましたMNaNの各行の値の量を数え、Xcベクトルに配置しCIます。
  5. のいずれかの行がでCIある場合> [Bootstrap sample size, for this case (200) - 1]、この時点で信頼区間を作成することはできません。

これを実行すると、セットXから選択された値がほとんど常に繰り返されていることがわかります。つまり、のXすべてのサンプルを生成するために同じ値が使用されMます。これは、新しいブートストラップサンプルを作成するために常に選択される、元の時系列の約200のデータポイントとほぼ同じです。

プログラムを効果的に変更したり、(5)の否定的な解決策を回避できる特定の機能を使用したりするにはどうすればよいですか?

これが私のコードの例ですが、スクリプトで使用される変数がここの私のテキストと異なる場合があることに注意してください。

助けてくれてありがとう、そして以下のコードを見てください。

for ii = 1:1:Blen % for loop to create 'how many bootstraps we desire'
    B = randsample(Xtrain, wtrain, true); % bootstrap resamples of data series 'X' for 'how many elements' with replacement
    rng('shuffle');
    M(:,ii) = B; % creates a matrix of all bootstrap resamples with respect to the amount created by the for loop
    [C,IA] = setdiff(Xtrain,B); % creates a vector containing all elements of 'Xtrain' that were not included in bootstrap sample 'ii' and the location of each element
    [IAc] = setdiff(k,IA); % creates a vector containing locations of elements of 'Xtrain' used in bootstrap sample 'ii' --> ***IA + IAc = wtrain***

    for j = 1:1:wtrain % for loop that counts each row of vector
            if ismember(j,IA)== 1 % if the count variable is equal to a value of 'IA'
                XC(j,ii) = Xtrain(j,1); % place variable in matrix for sample 'ii' in position 'j' if statement above is true
            else
                XC(j,ii) = NaN; % hold position with a NaN value to state that this value has been used in bootstrap sample 'ii'
            end
            dum1(:,ii) = wtrain - sum(isnan(XC(:,ii))); % dummy variable to permit transposing of 'IAs' limited by 'isnan' --> used to calculate amt of elements in IA
            dum2(:,ii) = sum(isnan(XC(:,ii))); % dummy variable to permit transposing of 'IAsc' limited by 'isnan' 
            IAs = transpose(dum1) ; % variable counting amount of elements not resampled in 'M' at set 'i', ***i.e. counts 'IA' for each resample set 'i'
            IAsc = transpose(dum2) ; % variable counting amount of elements resampled in 'M' at set 'i', ***i.e. counts 'IAc' for each resample set 'i'
            chk = isnan(XC); % returns 1 in position of NaN and 0 in position of actual value
            chks = sum(chk,2); % counts how many NaNs are in each row for length of time training set
            chks_cnt = sum(chks(:)<(Blen-1)); % counts how many values of the original time series that can be provided a confidence interval, should = wtrain to provide complete CIs
    end
end
4

1 に答える 1

0

これはrandsampleの問題ではなく、他のコードのどこかにある問題のようです。randsampleは正しいことをします。例えば:

x = (1:10)';
nSamples = 10;
for iter = 1:100; 
   data(:,iter) =  randsample(x,nSamples ,true); 
end; 

hist(data(:)) %this is approximately uniform

randsampleサンプルはかなりランダムに...

于 2012-12-12T02:29:46.840 に答える