Skip to content

NormalDistribution: The Z-Score formula is actually the probability density function #166

@PeterKneale

Description

@PeterKneale

@s-andrews @ewels

Expected: The function below named getZScoreForValue should calculate the Z-Score.
Actual: The implementation is actually the probability density function (PDF) of the normal distribution at a given value

Looking at the code calling the function (and chatting with a colleague who knows more about FastQC's intention here) we came to the conclusion that the function is just misnamed and the behaviour of the code is correct but cant be sure.

If you can let me know either way i'll ensure that the function has the correct name and add unit tests demonstrating its behaviour.

https://github.com/s-andrews/FastQC/blob/master/uk/ac/babraham/FastQC/Statistics/NormalDistribution.java

public class NormalDistribution {

	private double mean;
	private double stdev;
	
	public NormalDistribution (double mean, double stdev) {
		this.mean = mean;
		this.stdev = stdev;
	}
	
	public double getZScoreForValue (double value) {
		double lhs = 1d/(Math.sqrt(2*Math.PI*stdev*stdev));
		double rhs = Math.pow(Math.E, 0 - (Math.pow(value-mean,2)/(2*stdev*stdev)));		
		return lhs*rhs;
	}
}

ChatGPT helped to decipher the issue.

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions