HaskellAnalysisProgram-0.1.0: src/MetaHS/Extensions/MacroLevelAggregation/Average.hs
{-|
Module : MetaHS.MacroLevelAggregation
Description : The MetaHS Macro-level aggregation method: average
Copyright : Copyright (C) 2017-2019 H.H.R.F. Vos, S. Kamps
License : -- This file is distributed under the terms of the Apache License 2.0.
For more information, see the file "LICENSE", which is included in the distribution.
Stability : experimental
Calculates the average of the metric values corresponding to supplied Relation Key.
-}
module MetaHS.Extensions.MacroLevelAggregation.Average
where
import MetaHS.Extensions.MacroLevelAggregation.Utils
import qualified MetaHS.DataModel.MetaModel as MetaModel
import MetaHS.EDSL.MetaModel
-- | Calculate the average of the metric values associated with the supplied metric Relation key
average :: RelationKey -- ^ The MetaModel Relation Key (E.g., LCOM).
-> MetaModel.MetaModel -- ^ The MetaModel Containing the associated key.
-> Double -- ^ The average
average key mm = fromIntegral addition / fromIntegral valuesCount
where
addition = sum values
valuesCount = length values
values = getMetricElements key mm