lower and upper cusum

10 ビュー (過去 30 日間)
Amr Sadek
Amr Sadek 2023 年 3 月 26 日
編集済み: Adam Danz 2023 年 3 月 26 日
Hello,
I'm trying to use the cusum to evaluate the upper and lower cumulative sums as;
y=random('normal', 7.0,0.1,10,1); [iu il Cp Cm]=cusum(y);
However, the evaluated Cp and Cm do not match the figure when use
cusum(y);

採用された回答

Adam Danz
Adam Danz 2023 年 3 月 26 日
編集済み: Adam Danz 2023 年 3 月 26 日
Notice the ylabel in the plot generated by cusum. It's standard error. To convert the upper and lower sums to standard error, divide the Cp and Cm by the target standard deviation value shown in the title of the axes.
Note that if you don't provide cusum with the target mean and target standard deviation, those values are computed internally based on up to the first 25 samples of your data (see doc page).
Here's how to compute those lines given your inputs.
y=random('normal', 7.0,0.1,10,1);
% produce plot
cusum(y)
% Compute std-error based on first 25 samples
[iu il Cp Cm]=cusum(y);
ySamples = y(1:min(25,numel(y)));
t = max(eps(class(y)),std(ySamples));
CpStdErr = Cp/t;
CmStdErr = Cm/t;
% Plot dashed lines showing the computed values.
hold on
plot(1:numel(CpStdErr),CpStdErr, 'b--','LineWidth',2)
plot(1:numel(CmStdErr),CmStdErr, 'r--','LineWidth',2)
  1 件のコメント
Amr Sadek
Amr Sadek 2023 年 3 月 26 日
Thanks Adam, it works.

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

その他の回答 (1 件)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023 年 3 月 26 日
Note that every time, when you run the command it generates a new set of values. Thus, use rng():
rng('default')
y=random('normal', 7.0,0.1,10,1);
[iu il Cp Cm]=cusum(y)
iu = 0×1 empty double column vector il = 0×1 empty double column vector
Cp = 10×1
0 0.0325 0 0 0 0 0 0 0.2069 0.3329
Cm = 10×1
0 0 -0.1998 -0.0875 -0.0296 -0.1343 -0.1516 -0.0913 0 0
% OR specify the seed value, e.g., 13
rng(13)
y=random('normal', 7.0,0.1,10,1);
[iu il Cp Cm]=cusum(y)
iu = 0×1 empty double column vector il = 0×1 empty double column vector
Cp = 10×1
0 0 0.0504 0.0290 0.1130 0 0 0.0080 0 0
Cm = 10×1
0 -0.1428 -0.0016 0 0 -0.0383 -0.0199 0 0 0
% Test the seed value, e.g., 13
rng(13)
y=random('normal', 7.0,0.1,10,1);
[iu il Cp Cm]=cusum(y)
iu = 0×1 empty double column vector il = 0×1 empty double column vector
Cp = 10×1
0 0 0.0504 0.0290 0.1130 0 0 0.0080 0 0
Cm = 10×1
0 -0.1428 -0.0016 0 0 -0.0383 -0.0199 0 0 0

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by