blob: 0e0c4f50f8972165fbdab0e0b574ed82a4fa431e [file]
#-------------------------------------------------------------
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
#-------------------------------------------------------------
# This outlier-function takes a matrix data set as input from where it determines
# which point(s) have the largest difference from mean.
#
# INPUT:
# ------------------------------------------------------------------------------------------
# X Matrix of Recoded dataset for outlier evaluation
# opposite (1)TRUE for evaluating outlier from upper quartile range,
# (0)FALSE for evaluating outlier from lower quartile range
# ------------------------------------------------------------------------------------------
#
# OUTPUT:
# ---------------------------------------------------------------------------------------
# Y matrix indicating outlier values
# ---------------------------------------------------------------------------------------
m_outlier = function(Matrix[Double] X, Boolean opposite) return (Matrix[Double] Y) {
# determine if largest value has largest diff from mean
I = (colMaxs(X)-colMeans(X)) > (colMeans(X)-colMins(X));
# opposite: if largest value has largest diff from the mean, it gives smallest and vice versa
Y = ifelse(xor(I,opposite), colMaxs(X), colMins(X));
}