Cody

# Problem 661. Spot the outlier

Solution 716051

Submitted on 17 Aug 2015 by Eric G.
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
%% pts = [0 1; 0 2; 3 2; 0 3; 0 4 ]; outlier = 3; assert(isequal(spot_the_outlier(pts),outlier))

slopes = NaN 0 3.0000 0 0 0 NaN -Inf 0 0 3.0000 Inf NaN -3.0000 -1.5000 0 0 -3.0000 NaN 0 0 0 -1.5000 0 NaN M1 = 0 0 -Inf 0 0 M2 = 0

2   Pass
%% pts = [10 -1;7 0;9.5 0.3;9 1.6;8.5 2.9]; outlier = 2; assert(isequal(spot_the_outlier(pts),outlier))

slopes = NaN -3.0000 -0.3846 -0.3846 -0.3846 -3.0000 NaN 8.3333 1.2500 0.5172 -0.3846 8.3333 NaN -0.3846 -0.3846 -0.3846 1.2500 -0.3846 NaN -0.3846 -0.3846 0.5172 -0.3846 -0.3846 NaN M1 = -0.3846 -3.0000 -0.3846 -0.3846 -0.3846 M2 = -0.3846

3   Pass
%% pts = [-0.6 -6;-0.2 0;0 3;-0.8 -9;-2 1;-0.4 -3]; outlier = 5; assert(isequal(spot_the_outlier(pts),outlier))

slopes = NaN 0.0667 0.0667 0.0667 -0.2000 0.0667 0.0667 NaN 0.0667 0.0667 -1.8000 0.0667 0.0667 0.0667 NaN 0.0667 1.0000 0.0667 0.0667 0.0667 0.0667 NaN -0.1200 0.0667 -0.2000 -1.8000 1.0000 -0.1200 NaN -0.4000 0.0667 0.0667 0.0667 0.0667 -0.4000 NaN M1 = 0.0667 0.0667 0.0667 0.0667 -1.8000 0.0667 M2 = 0.0667

4   Pass
%% pts = [2 5;0 4;0 0;4 6;-2 3]; outlier = 3; assert(isequal(spot_the_outlier(pts),outlier))

slopes = NaN 2.0000 0.4000 2.0000 2.0000 2.0000 NaN 0 2.0000 2.0000 0.4000 0 NaN 0.6667 -0.6667 2.0000 2.0000 0.6667 NaN 2.0000 2.0000 2.0000 -0.6667 2.0000 NaN M1 = 2.0000 2.0000 -0.6667 2.0000 2.0000 M2 = 2

5   Pass
%% pts = [1 0; 0 1; 1 2; 1.5 2.5; 2 3; 3 4 ]; outlier = 1; assert(isequal(spot_the_outlier(pts),outlier))

slopes = NaN -1.0000 0 0.2000 0.3333 0.5000 -1.0000 NaN 1.0000 1.0000 1.0000 1.0000 0 1.0000 NaN 1.0000 1.0000 1.0000 0.2000 1.0000 1.0000 NaN 1.0000 1.0000 0.3333 1.0000 1.0000 1.0000 NaN 1.0000 0.5000 1.0000 1.0000 1.0000 1.0000 NaN M1 = -1 1 1 1 1 1 M2 = 1