<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Java Resources</title>
	<atom:link href="http://www.javaresources.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.javaresources.org</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Thu, 22 Apr 2010 08:48:19 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Pearson correlation coefficient</title>
		<link>http://www.javaresources.org/pearson-correlation-coefficient/</link>
		<comments>http://www.javaresources.org/pearson-correlation-coefficient/#comments</comments>
		<pubDate>Thu, 22 Apr 2010 07:50:48 +0000</pubDate>
		<dc:creator>teddy</dc:creator>
				<category><![CDATA[Objects and Classes]]></category>
		<category><![CDATA[correlation]]></category>
		<category><![CDATA[Pearson]]></category>

		<guid isPermaLink="false">http://www.javaresources.org/?p=39</guid>
		<description><![CDATA[In statistics, the Pearson product-moment correlation coefficient (sometimes referred to as the PMCC, and typically denoted by r) is a measure of the correlation (linear dependence) between two variables X and Y, giving a value between +1 and −1 inclusive.

    /**
     *   calculate Pearson product-moment correlation [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.javaresources.org/wp-content/uploads/2010/04/pearson.png"><img class="alignleft size-medium wp-image-40" title="pearson" src="http://www.javaresources.org/wp-content/uploads/2010/04/pearson-300x45.png" alt="" width="300" height="45" /></a>In statistics, the Pearson product-moment correlation coefficient (sometimes referred to as the PMCC, and typically denoted by r) is a measure of the correlation (linear dependence) between two variables X and Y, giving a value between +1 and −1 inclusive.</p>
<pre class="brush:java">
    /**
     *   calculate Pearson product-moment correlation coefficient
     * @param point1     first point
     * @param point2     second point
     * @return     Pearson correlation coefficient
     */
    public static double getPMCC(double[] point1, double[] point2) {
        double suma = 0;
        double sumb = 0;
        double sumaSq = 0;
        double sumbSq = 0;
        double pSum = 0;
        int n = point1.length;
        for (int i = 0; i < point1.length; i++) {
            suma = suma + point1[i];
            sumb = sumb + point2[i];
            sumaSq = sumaSq + point1[i] * point1[i];
            sumbSq = sumbSq + point2[i] * point1[i];
            pSum = pSum + point1[i] * point2[i];
        }
        double numerator = pSum - suma * sumb / n;
        double denominator = Math.sqrt((sumaSq - suma * suma / n) * (sumbSq - sumb * sumb / n));
        return numerator / denominator;
    }
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.javaresources.org/pearson-correlation-coefficient/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Normalization</title>
		<link>http://www.javaresources.org/normalization/</link>
		<comments>http://www.javaresources.org/normalization/#comments</comments>
		<pubDate>Thu, 22 Apr 2010 07:39:22 +0000</pubDate>
		<dc:creator>teddy</dc:creator>
				<category><![CDATA[Java algorithms]]></category>
		<category><![CDATA[Normalization]]></category>

		<guid isPermaLink="false">http://www.javaresources.org/?p=36</guid>
		<description><![CDATA[Normalization is any process  that makes something more normal.

    /**
     * @param point1 first point
     * @param point2 second point
     * @return the  normalization Euclidean distance of two points
     */
    public [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Normalization</strong> is any process  that makes something more normal.</p>
<pre class="brush:java">
    /**
     * @param point1 first point
     * @param point2 second point
     * @return the  normalization Euclidean distance of two points
     */
    public static double getNormalizeDistance(double[] point1, double[] point2) {
        return 1 / (getDistance(point1, point2) + 1);
    }
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.javaresources.org/normalization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Euclidean distance</title>
		<link>http://www.javaresources.org/euclidean-distance/</link>
		<comments>http://www.javaresources.org/euclidean-distance/#comments</comments>
		<pubDate>Tue, 20 Apr 2010 06:12:14 +0000</pubDate>
		<dc:creator>teddy</dc:creator>
				<category><![CDATA[Java algorithms]]></category>
		<category><![CDATA[Euclidean distance]]></category>

		<guid isPermaLink="false">http://www.javaresources.org/?p=29</guid>
		<description><![CDATA[In mathematics, the Euclidean distance or Euclidean metric is the &#8220;ordinary&#8221; distance  between two points that one would measure with a ruler, and is given by the Pythagorean formula.
    /**
     * @param point1   first point
     * @param point2   second [...]]]></description>
			<content:encoded><![CDATA[<p>In mathematics, the Euclidean distance or Euclidean metric is the &#8220;ordinary&#8221; distance  between two points that one would measure with a ruler, and is given by the Pythagorean formula.</p>
<pre class="brush:java">    /**
     * @param point1   first point
     * @param point2   second point
     * @return  the  Euclidean distance of two points
     */
    public static double getDistance(double[] point1, double[] point2) {
        double distance = 0;
        for (int i = 0; i &lt; point1.length; i++) {
            distance = distance + Math.pow((point1[i] - point2[i]), 2);
        }
        return Math.sqrt(distance);
    }
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.javaresources.org/euclidean-distance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Gaussian distribution</title>
		<link>http://www.javaresources.org/gaussian-distribution/</link>
		<comments>http://www.javaresources.org/gaussian-distribution/#comments</comments>
		<pubDate>Fri, 09 Apr 2010 06:02:05 +0000</pubDate>
		<dc:creator>teddy</dc:creator>
				<category><![CDATA[Java algorithms]]></category>
		<category><![CDATA[Gaussian distribution]]></category>

		<guid isPermaLink="false">http://www.javaresources.org/?p=26</guid>
		<description><![CDATA[The normal distribution or Gaussian distribution is a continuous probability distribution that often gives a good description of data that cluster around the mean. 

    /**
     *   The aim of this static method is to implememnt the function of Gaussian distribution
     * [...]]]></description>
			<content:encoded><![CDATA[<p>The normal distribution or Gaussian distribution is a continuous probability distribution that often gives a good description of data that cluster around the mean. </p>
<pre class="brush:java">
    /**
     *   The aim of this static method is to implememnt the function of Gaussian distribution
     *   N（μ，σ2)
     * @param x   variable
     * @param mean   mathematic expectation
     * @param stdDev Variance
     * @return
     */
    public static double normalDens(double x, double mean, double stdDev) {
         double diff = x - mean;
         return (1 / ( Math.sqrt(2 * Math.PI) * stdDev))
                 * Math.exp(-(diff * diff / (2 * stdDev * stdDev)));
     }
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.javaresources.org/gaussian-distribution/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Gaussian elimination</title>
		<link>http://www.javaresources.org/gaussian-elimination/</link>
		<comments>http://www.javaresources.org/gaussian-elimination/#comments</comments>
		<pubDate>Tue, 30 Mar 2010 12:47:23 +0000</pubDate>
		<dc:creator>teddy</dc:creator>
				<category><![CDATA[Java algorithms]]></category>
		<category><![CDATA[Gaussian]]></category>
		<category><![CDATA[Gaussian elimination]]></category>

		<guid isPermaLink="false">http://www.javaresources.org/?p=9</guid>
		<description><![CDATA[In linear algebra, Gaussian elimination is an algorithm  for solving systems of linear equations, finding the rank of a matrix, and calculating the inverse of an invertible square matrix.
Gauss-Jordan Elimination is a variant of Gaussian Elimination.

package org.javaresources.math.matrix;
/**
 * Created by IntelliJ IDEA.
 * User: glen
 * Date: 2010-3-29
 * Time: 20:10:28
 *
 */
public class MatrixUtil [...]]]></description>
			<content:encoded><![CDATA[<p>In linear algebra, Gaussian elimination is an algorithm  for solving systems of linear equations, finding the rank of a matrix, and calculating the inverse of an invertible square matrix.</p>
<p>Gauss-Jordan Elimination is a variant of Gaussian Elimination.</p>
<pre class="brush:java">
package org.javaresources.math.matrix;
/**
 * Created by IntelliJ IDEA.
 * User: glen
 * Date: 2010-3-29
 * Time: 20:10:28
 *
 */
public class MatrixUtil {
    /**
     *   Ax=b
     * @param a A  matrix
     * @param b b  vector
     */
    public static void gaussJordan(double a[][], double b[]){
        int i, j, k, m;
        double temp;
        int numRows = a.length;
        int numCols = a[0].length;
        int index[][] = new int[numRows][2];
        partialPivot(a, b, index);
        for (i = 0; i < numRows; ++i) {
            temp = a[i][i];
            for (j = 0; j < numCols; ++j) {
                a[i][j] /= temp;
            }
            b[i] /= temp;
            a[i][i] = 1.0 / temp;
            for (k = 0; k < numRows; ++k) {
                if (k != i) {
                    temp = a[k][i];
                    for (j = 0; j < numCols; ++j) {
                        a[k][j] -= temp * a[i][j];
                    }
                    b[k] -= temp * b[i];
                    a[k][i] = -temp * a[i][i];
                }
            }
        }
        for (j = numCols - 1; j >= 0; --j) {
            k = index[j][0];
            m = index[j][1];
            if (k != m) {
                for (i = 0; i < numRows; ++i) {
                    temp = a[i][m];
                    a[i][m] = a[i][k];
                    a[i][k] = temp;
                }
            }
        }
        return;
    }
    /**
     *
     * @param mt  matrix
     * @param v     vector
     * @param index
     */
    private static void partialPivot(
            double mt[][], double v[], int index[][]) {
        double temp;
        double tempRow[];
        int i, j, m;
        int numRows = mt.length;
        int numCols = mt[0].length;
        double scale[] = new double[numRows];
        for (i = 0; i < numRows; ++i) {
            index[i][0] = i;
            index[i][1] = i;
            for (j = 0; j < numCols; ++j) {
                scale[i] = Math.max(scale[i], Math.abs(mt[i][j]));
            }
        }
        for (j = 0; j < numCols - 1; ++j) {
            m = j;
            for (i = j + 1; i < numRows; ++i) {
                if (Math.abs(mt[i][j]) / scale[i] >
                        Math.abs(mt[m][j]) / scale[m]) {
                    m = i;
                }
            }
            if (m != j) {
                index[j][0] = j;
                index[j][1] = m;
                tempRow = mt[j];
                mt[j] = mt[m];
                mt[m] = tempRow;
                temp = v[j];
                v[j] = v[m];
                v[m] = temp;
                temp = scale[j];
                scale[j] = scale[m];
                scale[m] = temp;
            }
        }
    }

    /**
     *    Inverse matrix
     * @param a
     */
    public static void invertMatrix(double a[][]) {
        int i, j, k, m;
        double temp;

        int numRows = a.length;
        int numCols = a[0].length;
        int index[][] = new int[numRows][2];
        partialPivot(a, new double[numRows], index);
        for (i = 0; i < numRows; ++i) {
            temp = a[i][i];
            for (j = 0; j < numCols; ++j) {
                a[i][j] /= temp;
            }
            a[i][i] = 1.0 / temp;
            for (k = 0; k < numRows; ++k) {
                if (k != i) {
                    temp = a[k][i];
                    for (j = 0; j < numCols; ++j) {
                        a[k][j] -= temp * a[i][j];
                    }
                    a[k][i] = -temp * a[i][i];
                }
            }
        }
        for (j = numCols - 1; j >= 0; --j) {
            k = index[j][0];
            m = index[j][1];
            if (k != m) {
                for (i = 0; i < numRows; ++i) {
                    temp = a[i][m];
                    a[i][m] = a[i][k];
                    a[i][k] = temp;
                }
            }
        }
    }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.javaresources.org/gaussian-elimination/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mysql + JSP Example</title>
		<link>http://www.javaresources.org/mysql-jsp-sample/</link>
		<comments>http://www.javaresources.org/mysql-jsp-sample/#comments</comments>
		<pubDate>Sun, 28 Mar 2010 14:00:27 +0000</pubDate>
		<dc:creator>teddy</dc:creator>
				<category><![CDATA[JSP Basics]]></category>
		<category><![CDATA[JDBC]]></category>

		<guid isPermaLink="false">http://www.javaresources.org/?p=5</guid>
		<description><![CDATA[Java Database Connectivity (JDBC) is an API that lets you access any tabular data sources from a Java application.
This example shows a JSP that queries a UserInfo table using JDBC.











Name
password








]]></description>
			<content:encoded><![CDATA[<p>Java Database Connectivity (JDBC) is an API that lets you access any tabular data sources from a Java application.<br />
This example shows a JSP that queries a UserInfo table using JDBC.</p>
<pre class="brush:java">

<html>
<head>

</head>
<body>
<%@ page language="java" import="java.sql.*, java.io.*" %>
<%
    Connection con = null;
    try{
        Class.forName("com.mysql.jdbc.Driver");
        con = DriverManager.getConnection("jdbc:mysql://localhost/blog?user=root&#038;password=123456");
        Statement statement = con.createStatement();
        ResultSet rs = statement.executeQuery("SELECT * FROM userinfo");

%>
<table border="1">
<tr>
<th>Name</th>
<th>password</th>

<%
        while ( rs.next() ) {
            out.println("
<tr>\n
<td>" + rs.getString("username") + "</td>

");
            out.println("
<td>" + rs.getString("password") + "</td>

");
        }
        rs.close();
    } catch (IOException io) {
        out.println(io.getMessage());
    } catch (SQLException sql) {
        out.println(sql.getMessage());
    } catch (Exception e) {
        out.println(e.getMessage());
    } finally {
        try {
            if ( con != null ) {
                con.close();
            }
        } catch (SQLException sql) {
            out.println(sql.getMessage());
        }
    }
%>
</tr>
</table>

</body>
</html>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.javaresources.org/mysql-jsp-sample/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Mysql  Connection</title>
		<link>http://www.javaresources.org/hello-world/</link>
		<comments>http://www.javaresources.org/hello-world/#comments</comments>
		<pubDate>Sun, 28 Mar 2010 03:49:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JSP Basics]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.javaresources.org/?p=1</guid>
		<description><![CDATA[
public static Connection getConnection() throws Exception {
String driver = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://localhost/ev?";
String username = "root";
String password = "0532";
Class.forName(driver); // load Oracle driver
return DriverManager.getConnection(url, username, password);
}

]]></description>
			<content:encoded><![CDATA[<pre class="brush:java">
public static Connection getConnection() throws Exception {
String driver = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://localhost/ev?";
String username = "root";
String password = "0532";
Class.forName(driver); // load Oracle driver
return DriverManager.getConnection(url, username, password);
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.javaresources.org/hello-world/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
