// compare compares the given two samples using Mann-Whitney U test.
// Considered as failure if it deviates in the specified direction as the third argument.
compare compares the given two samples using Mann-Whitney U test.
Considered as failure if it deviates in the specified direction as the third argument.
// compare compares the given two samples using Mann - Whitney U test . // Considered as failure if it deviates in the specified direction as the third argument .
func compare(experiment, control []float64, deviation string) (acceptable bool, err error) {
	if len(experiment) == 0 {
		return false, fmt.Errorf("no data points of Experiment found")
	}
	if len(control) == 0 {
		return false, fmt.Errorf("no data points of Control found")
	}
	var alternativeHypothesis mannwhitney.LocationHypothesis
	switch deviation {
	case config.AnalysisDeviationEither:
		alternativeHypothesis = mannwhitney.LocationDiffers
	case config.AnalysisDeviationLow:
		alternativeHypothesis = mannwhitney.LocationLess
	case config.AnalysisDeviationHigh:
		alternativeHypothesis = mannwhitney.LocationGreater
	default:
		return false, fmt.Errorf("unknown deviation %q given", deviation)
	}
	res, err := mannwhitney.MannWhitneyUTest(experiment, control, alternativeHypothesis)
	if errors.Is(err, mannwhitney.ErrSamplesEqual) {
		return true, nil
	}
	if err != nil {
		return false, fmt.Errorf("failed to perform the Mann-Whitney U test: %w", err)
	}
	const alpha = 0.05
	if res.P > alpha {
		return true, nil
	}
	return false, nil
}
func compare ( experiment , control [ ] float64 , deviation string ) ( acceptable bool , err error ) { if len ( experiment ) == 0 { return false , fmt . Errorf ( " " ) } if len ( control ) == 0 { return false , fmt . Errorf ( " " ) } var alternativeHypothesis mannwhitney . LocationHypothesis switch deviation { case config . AnalysisDeviationEither : alternativeHypothesis = mannwhitney . LocationDiffers case config . AnalysisDeviationLow : alternativeHypothesis = mannwhitney . LocationLess case config . AnalysisDeviationHigh : alternativeHypothesis = mannwhitney . LocationGreater default : return false , fmt . Errorf ( " " , deviation ) } res , err := mannwhitney . MannWhitneyUTest ( experiment , control , alternativeHypothesis ) if errors . Is ( err , mannwhitney . ErrSamplesEqual ) { return true , nil } if err != nil { return false , fmt . Errorf ( " " , err ) } const alpha = 0.05 if res . P > alpha { return true , nil } return false , nil }
compare compares the given two samples using Mann-Whitney U test.
compare compares the given two samples using Mann - Whitney U test .
// All samples are exact the same. // alpha is the significance level. Typically 5% is used. // If the p-value is greater than the significance level, // we cannot say that the distributions in the two groups differed significantly. // See: https://support.minitab.com/en-us/minitab-express/1/help-and-how-to/basic-statistics/inference/how-to/two-samples/mann-whitney-test/interpret-the-results/key-results/