Write Standard Deviation Distance
15 次查看(过去 30 天)
显示 更早的评论
I am asked to write a function called standard_deviation_distance that takes as input a data vector [1xN] v and a number x [1x1], in that order. And I have code to call your function:
v = [10 12 14];
x = 7;
dist = standard_deviation_distance(v,x)% =-2.5
0 个评论
回答(3 个)
VBBV
2022-6-5
编辑:VBBV
2022-11-10
v = [10 12 14];
x = ones(1,numel(v))*7;% length of x vector (weights) for each element and to be same as vector v
dist = standard_deviation_distance(v,x);
disp(['The standard deviation distance is ', num2str(dist)])
function y = standard_deviation_distance(v,x)
y = std(v,x);
end
0 个评论
Himanshu Desai
2023-5-31
编辑:Himanshu Desai
2023-5-31
function y = standard_deviation_distance(v,x)
m = mean(v);
s = std(v);
y = (x-m)/s;
end
dist = -2.500
v = [10 12 14];
x = 7;
y = standard_deviation_distance(v,x)
0 个评论
Mark
2025-8-1
编辑:Walter Roberson
2025-8-1
v = [10 12 14];
x = ones(1, numel(v))*7;
dist = std(v,x)
disp(['The standard deviation distance is ' num2str(dist)])
3 个评论
Walter Roberson
2025-8-2
@VBBV solution involved a function (as was required by the terms of the question)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Polynomials 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!