public void run()
    {
       
        if(this.sampleSize==-1) 
        {
            this.TGA();
        }
        else {
            String arr[] = this.outputFilename.split("\\.(?=[^\\.]+$)");
            
            double n = this.sampleSize;
            double sum = 0;
            double sum2 = 0;
            double prom = 0;
            double var = 0;
            double v;
            Genotipo best = null;
            Genotipo worst = null;
            Genotipo g;
            
            for(int i=1; i<=this.sampleSize; i++) {
                this.outputFilename = String.format("%s_%d.%s", arr[0], i, arr[1]);
                g = this.TGA();
                v = g.getFitnessValue();
                sum += v;
                sum2 += v*v;
                if(i==1) {
                    best = g;
                    worst = g;
                }
                if(comp.compare(g, best) < 0) {
                    best = g;
                }
                if(comp.compare(g, worst) > 0) {
                    worst = g;
                }
            }
            //calculamos
            prom = sum/n;
            var = 1/(n-1)*(sum2 - n*prom*prom);
            
            //imprimimos
            PrintWriter pw;
            try {
                pw = new PrintWriter(
                            new File(
                                String.format("%s_%s.%s", arr[0], "stat", arr[1])));
                pw.println("TGA - eliTist Genetic Algorithm");
                pw.printf("\"Funcion\", %s\n",  "\"" +func.toString() +"\"");
                pw.printf("\"Promedio\", %f\n", prom);
                pw.printf("\"Varianza\", %f\n", var);
                pw.printf("\"Desv.Est\", %f\n", Math.sqrt(var));
                pw.printf("\"Mejor Fitness\", %f\n", best.getFitnessValue());
                pw.printf("\"Mejor Genoma\", %s\n", func.getFenotipo(best));
                pw.printf("\"Peor Fitness\", %f\n", worst.getFitnessValue());
                pw.printf("\"Peor Genoma\", %s\n", func.getFenotipo(worst));
                pw.close();
            }
            catch(Exception e) {
                System.err.println("Hubo un error al abrir el " +
                                    "archivo de salida de estadisticas");
                System.exit(1);
            }
        }
    }