Cody

Solution 1942649

Submitted on 19 Sep 2019 at 11:45 by Eyal Soreq
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
m = 100; n = 10; x = rand(m,n); k = false(1,n); k(randi(n,1,3)) = true; x(:,k) = rand; tol = 1.0e-12; out = zscore(x); assert(isstruct(out),'Struct test failed.') assert(isfield(out,'Z'),'Z field test failed.') assert(isfield(out,'Mu'),'Mu field test failed.') assert(isfield(out,'Sigma'),'Sigma field test failed.') assert(isequal(size(x),size(out.Z)),'Z size test failed.') assert(isequal(size(x(1,:)),size(out.Mu)),'Mu size test failed.') assert(isequal(size(x(1,:)),size(out.Sigma)),'Sigma size test failed.') assert(all(abs(mean(out.Z))<tol),'Mean test failed.') assert(all(abs(std(out.Z(:,~k))-1)<tol),'STD test failed.') assert(all(abs(std(out.Z(:,k)))<tol),'STD test for invariant data failed.') assert(isequal(out.Mu,mean(x,1)),'Mean equality test failed.') assert(isequal(out.Sigma,std(x,0,1)),'STD equality test failed.')

2   Pass
m = 100; n = 10; rng(2000,'twister') x = rand(m,n); k = false(1,n); k(randi(n,1,3)) = true; x(:,k) = rand; tol = 1.0e-12; out = zscore(x); assert(isstruct(out),'Struct test failed.') assert(isfield(out,'Z'),'Z field test failed.') assert(isfield(out,'Mu'),'Mu field test failed.') assert(isfield(out,'Sigma'),'Sigma field test failed.') assert(isequal(size(x),size(out.Z)),'Z size test failed.') assert(isequal(size(x(1,:)),size(out.Mu)),'Mu size test failed.') assert(isequal(size(x(1,:)),size(out.Sigma)),'Sigma size test failed.') assert(all(abs(mean(out.Z))<tol),'Mean test failed.') assert(all(abs(std(out.Z(:,~k))-1)<tol),'STD test failed.') assert(all(abs(std(out.Z(:,k)))<tol),'STD test for invariant data failed.') assert(isequal(out.Mu,mean(x,1)),'Mean equality test failed.') assert(isequal(out.Sigma,std(x,0,1)),'STD equality test failed.')