Skip to content

Instantly share code, notes, and snippets.

@cristianmiranda
Created June 18, 2015 19:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cristianmiranda/3acb4f2afe26770fc485 to your computer and use it in GitHub Desktop.
Save cristianmiranda/3acb4f2afe26770fc485 to your computer and use it in GitHub Desktop.
Estimadores poblacionales
private double[] getValues() {
return new double[]{ 100, 115, 70, 115, 75, 80, 100, 90, 100, 95 };
}
@Test
public void calculateEstimatedParameters() {
double[] values = getValues();
double sum = 0D;
for (double value : values) {
sum += value;
}
double mean = sum / values.length;
double variance = 1D / new Double(values.length - 1) * (summary(values) - values.length * Math.pow(mean, 2));
System.out.println("Media: " + mean);
System.out.println("Varianza: " + variance);
System.out.println("Desvío: " + Math.sqrt(variance));
}
private double summary(double[] values) {
double sum = 0D;
for (double value : values) {
sum += Math.pow(value, 2);
}
return sum;
}
@leonardoriviere
Copy link

What a gross person!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment