フィルターのクリア

plotting using a box plot

1 回表示 (過去 30 日間)
fafz1203
fafz1203 2016 年 10 月 18 日
編集済み: Walter Roberson 2016 年 10 月 18 日
The following MATLAB code works correctly. After making this calculations I want to do 100 realizations of the training data (xTrain and yTrain). By that I mean, basically run it 100 times with different xTrain and yTrain. After that I want to plot these values I got on a box plot. Please see the attached image below to illustrate the box plot I want. Can anyone help with this.
Let me know if anything is unclear.
sigma = eye(10);
mu = repelem(zeros,10);
sd1 = 0.01; sd2 = 0.1; sd3 = 0.25;
xTrain = mvnrnd(mu,sigma,1000);
xTest = mvnrnd(mu,sigma,1000);
betaTruth = (mvnrnd (mu,sigma))';
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
epTest1 = noise(sd1); epTest2 = noise(sd2); epTest3 = noise(sd3);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
yTest1 = yValues(xTest,betaTruth,epTest1);
yTest2 = yValues(xTest,betaTruth,epTest2);
yTest3 = yValues(xTest,betaTruth,epTest3);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
betaHat1 = beta(xTrain,yTrain1);
betaHat2 = beta(xTrain,yTrain2);
betaHat3 = beta(xTrain,yTrain3);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
testError1 = error(xTest,betaHat1,yTest1);
testError2 = error(xTest,betaHat2,yTest2);
testError3 = error(xTest,betaHat3,yTest3);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function n = noise(x)
n = x.*randn(1000,1);
end
function e = error(x,b,y)
diff = ((x*b) - y).^2;
e = sum (diff(:))/1000;
end
function y = yValues(x,b,n)
y = (x*b) + n;
end
function b = beta(x,y)
b = (inv(x'*x)*x')*y;
end
  2 件のコメント
fafz1203
fafz1203 2016 年 10 月 18 日
the functions are found at the bottom
fafz1203
fafz1203 2016 年 10 月 18 日
Here is a picture of the plot I should obtain

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

回答 (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