public override bool Check(IEnumerable <double> data, out string errorMsg) { ConfigureParameters(data); errorMsg = ""; if (OriginalStandardDeviation.IsAlmost(0.0)) { errorMsg = "Standard deviaton for the original data is 0.0, Transformation cannot be applied onto these values."; return(false); } return(true); }
public override IEnumerable <double> Apply(IEnumerable <double> data) { if (OriginalStandardDeviation.IsAlmost(0.0)) { return(data); } var old_m = OriginalMean; var old_s = OriginalStandardDeviation; var m = Mean; var s = StandardDeviation; return(data .Select(d => (d - old_m) / old_s) // standardized .Select(d => d * s + m)); }