public NormalDistributionDouble(double[] array) { dataArray = array; sd = new StandardDeviation(dataArray); standardDeviation = (double)sd.GetResult(); mean = (double)sd.GetMean(); }
public override object GetHypothesisTestingForMean(object array, object m, object sigma, out object lessThan, out object greaterThan) { StandardDeviation sd = new StandardDeviation(array); if (!IsDouble(m) || !IsDouble(sigma)) { throw new ArgumentException(ERROR_ARGUMENT_DOUBLE); } var strongTypeDataDouble = array as double[]; double[] arrayDouble; if (strongTypeDataDouble != null) { arrayDouble = strongTypeDataDouble; } else { throw new ArgumentException(ERROR_ARGUMENT_DOUBLE_ARRAY); } double t = ((double)sd.GetMean() - (double)m) / ((double)sigma / Math.Sqrt(arrayDouble.Length)); StudentTDistributionDouble tDistribution = new StudentTDistributionDouble(arrayDouble.Length - 1, t); lessThan = (double)tDistribution.GetProbability(); greaterThan = 1 - (double)lessThan; return(t); }
public override object GetHypothesisTestingForMean(object array, object m, object sigma, out object lessThan, out object greaterThan) { StandardDeviation sd = new StandardDeviation(array); if (!IsDecimal(m) || !IsDecimal(sigma)) { throw new ArgumentException(ERROR_ARGUMENT_DECIMAL); } var strongTypeDataDecimal = array as decimal[]; decimal[] arrayDecimal; if (strongTypeDataDecimal != null) { arrayDecimal = strongTypeDataDecimal; } else { throw new ArgumentException(ERROR_ARGUMENT_DECIMAL_ARRAY); } decimal t = ((decimal)sd.GetMean() - (decimal)m) / ((decimal)sigma / Convert.ToDecimal(Math.Sqrt(arrayDecimal.Length))); StudentTDistributionDecimal tDistribution = new StudentTDistributionDecimal(arrayDecimal.Length - 1, t); lessThan = Convert.ToDecimal(tDistribution.GetProbability()); greaterThan = Convert.ToDecimal(1 - (decimal)lessThan); return(t); }
public override object GetHypothesisTestingForMean(object array, object m, object sigma, out object lessThan, out object greaterThan) { StandardDeviation sd = new StandardDeviation(array); if (!IsFloat(m) || !IsFloat(sigma)) { throw new ArgumentException(ERROR_ARGUMENT_FLOAT); } var strongTypeDataFloat = array as float[]; float[] arrayFloat; if (strongTypeDataFloat != null) { arrayFloat = strongTypeDataFloat; } else { throw new ArgumentException(ERROR_ARGUMENT_FLOAT_ARRAY); } float t = ((float)sd.GetMean() - (float)m) / ((float)sigma / Convert.ToSingle(Math.Sqrt(arrayFloat.Length))); StudentTDistributionFloat tDistribution = new StudentTDistributionFloat(arrayFloat.Length - 1, t); lessThan = Convert.ToSingle(tDistribution.GetProbability()); greaterThan = Convert.ToSingle(1 - (float)lessThan); return(t); }
public NormalDistributionDecimal(decimal[] array) { dataArray = array; sd = new StandardDeviation(dataArray); standardDeviation = (decimal)sd.GetResult(); mean = (decimal)sd.GetMean(); }
public NormalDistributionFloat(float[] array) { dataArray = array; sd = new StandardDeviation(dataArray); standardDeviation = (float)sd.GetResult(); mean = (float)sd.GetMean(); }
public override object GetTTestValue(object array1, object array2) { StandardDeviation sd1 = new StandardDeviation(array1); StandardDeviation sd2 = new StandardDeviation(array2); decimal array1Mean = (decimal)sd1.GetMean(); decimal array1SD = (decimal)sd1.GetResult(); decimal array2Mean = (decimal)sd2.GetMean(); decimal array2SD = (decimal)sd2.GetResult(); int length1 = (array1 as Array).Length; int length2 = (array2 as Array).Length; return((double)Math.Abs(array1Mean - array2Mean) / (Math.Sqrt(Math.Pow(Convert.ToDouble(array1SD), 2) / length1 + Math.Pow(Convert.ToDouble(array2SD), 2) / length2))); }
public override object GetTTestValue(object array1, object array2) { StandardDeviation sd1 = new StandardDeviation(array1); StandardDeviation sd2 = new StandardDeviation(array2); float array1Mean = (float)sd1.GetMean(); float array1SD = (float)sd1.GetResult(); float array2Mean = (float)sd2.GetMean(); float array2SD = (float)sd2.GetResult(); int length1 = (array1 as Array).Length; int length2 = (array2 as Array).Length; return(Math.Abs(array1Mean - array2Mean) / (Math.Sqrt(Math.Pow(array1SD, 2) / length1 + Math.Pow(array2SD, 2) / length2))); }
public override object GetCorrelationRatio() { StandardDeviation sd1 = new StandardDeviation(array1); StandardDeviation sd2 = new StandardDeviation(array2); double mean1 = (double)sd1.GetMean(); double mean2 = (double)sd2.GetMean(); double sum = 0; for (int i = 0; i < length; i++) { sum += (array1[i] - mean1) * (array2[i] - mean2); } return((sum / ((double)sd1.GetResult() * (double)sd2.GetResult())) / (length - 1)); }
public override void GetGreatFive(out object mean1, out object mean2, out object sigma1, out object sigma2, out object r) { StandardDeviation sd1 = new StandardDeviation(array1); StandardDeviation sd2 = new StandardDeviation(array2); mean1 = (double)sd1.GetMean(); mean2 = (double)sd2.GetMean(); sigma1 = (double)sd1.GetResult(); sigma2 = (double)sd2.GetResult(); double sum = 0; for (int i = 0; i < length; i++) { sum += (array1[i] - (double)mean1) * (array2[i] - (double)mean2); } r = (sum / ((double)sigma1 * (double)sigma2)) / (length - 1); }
public override object GetMean() { return(sd.GetMean()); }