Sha256: f33681c617d1f7316dd222b85e7c1db4f59a996a169a57cf2dd43fb25c6c3a37

Contents?: true

Size: 968 Bytes

Versions: 6

Compression:

Stored size: 968 Bytes

Contents

require 'spout/helpers/array_statistics'
require 'spout/helpers/json_loader'

module Spout
  module Models
    class OutlierResult
      attr_reader :csv_files, :method, :major_outliers, :minor_outliers, :outliers, :weight, :units, :median

      def initialize(subjects, method, csv_files)
        @values = subjects.collect(&method.to_sym)
        @csv_files = csv_files
        @method = method


        calculate_outliers!

        @weight = if @major_outliers.count > 0
          0
        elsif @minor_outliers.count > 0
          1
        else
          2
        end
        variable = Spout::Helpers::JsonLoader::get_variable(method)
        @units = (variable.kind_of?(Hash) ? variable['units'] : nil)
        @median = @values.median
      end

      def calculate_outliers!
        @major_outliers = @values.major_outliers.uniq
        @minor_outliers = @values.minor_outliers.uniq
        @outliers = @values.outliers.uniq
      end

    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
spout-0.8.0.beta12 lib/spout/models/outlier_result.rb
spout-0.8.0.beta11 lib/spout/models/outlier_result.rb
spout-0.8.0.beta10 lib/spout/models/outlier_result.rb
spout-0.8.0.beta9 lib/spout/models/outlier_result.rb
spout-0.8.0.beta8 lib/spout/models/outlier_result.rb
spout-0.8.0.beta7 lib/spout/models/outlier_result.rb