Write Standard Deviation Distance

15 visualizaciones (últimos 30 días)
Lisbeth Ccoyo Ortiz
Lisbeth Ccoyo Ortiz el 4 de Jun. de 2022
Comentada: Walter Roberson el 2 de Ag. de 2025
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

Respuestas (3)

VBBV
VBBV el 5 de Jun. de 2022
Editada: VBBV el 10 de Nov. de 2022
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)])
The standard deviation distance is 1.633
function y = standard_deviation_distance(v,x)
y = std(v,x);
end

Himanshu Desai
Himanshu Desai el 31 de Mayo de 2023
Editada: Himanshu Desai el 31 de Mayo de 2023
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)

Mark
Mark el 1 de Ag. de 2025
Editada: Walter Roberson el 1 de Ag. de 2025
v = [10 12 14];
x = ones(1, numel(v))*7;
dist = std(v,x)
dist = 1.6330
disp(['The standard deviation distance is ' num2str(dist)])
The standard deviation distance is 1.633
  3 comentarios
Torsten
Torsten el 1 de Ag. de 2025
Editada: Torsten el 1 de Ag. de 2025
I don't see a difference to @VBBV 's solution (except for "nume1" instead of "numel").
Maybe it was meant as "test test test".
Walter Roberson
Walter Roberson el 2 de Ag. de 2025
@VBBV solution involved a function (as was required by the terms of the question)

Iniciar sesión para comentar.

Categorías

Más información sobre Polynomials en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by