Package org.apache.commons.math.stat.descriptive.rank

Examples of org.apache.commons.math.stat.descriptive.rank.Median


    return meanCalculator.evaluate(values);
  }
 
  public static Double median(double[] values)
  {
    Median medianCalculator = new Median();
    return medianCalculator.evaluate(values);
  }
View Full Code Here


    public static double getMedianTestScore(int testID)
        throws SQLException
    {
        Logger              log = Logger.getLogger();
        boolean             loggingEnabled = log.isLoggingEnabled();
        Median              median = new Median();
        ArrayList           arraylist = new ArrayList();
        Connection          conn = getDefaultConnection();

        try {
            log.enableLogging( false );
           
            PreparedStatement   ps = Utils.prepare
                (
                 conn,
                 "select tk.score\n" +
                 "from TestTaking tk, LastTaking lt\n" +
                 "where tk.takingID = lt.takingID\n" +
                 "and tk.testID = ?\n"
                 );
           
            ps.setInt( 1, testID );
           
            ResultSet           rs = ps.executeQuery();
           
            while( rs.next() )
            {
                arraylist.add(new Double(rs.getDouble(1)));
            }
           
            Utils.close(rs);
            Utils.close(ps);
        }
        finally
        {
            log.enableLogging( loggingEnabled );
        }

        int                 count = arraylist.size();
        double              values[] = new double[ count ];

        for ( int i = 0; i < count; i++)
        { values[ i ] = ((Double)arraylist.get(i)).doubleValue(); }

        return median.evaluate( values );
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.math.stat.descriptive.rank.Median

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.