Note that there are some explanatory texts on larger screens.

plurals
  1. POConsole on eclipse doesn't show anything
    text
    copied!<p>I try to run the Java code on eclipse. There is code like "system.out.print" but when i press run the console show this...... </p> <p>Invalid layout of java.lang.String at value</p> <p>A fatal error has been detected by the Java Runtime Environment:</p> <p>Internal Error (javaClasses.cpp:136), pid=2276, tid=2148</p> <p>fatal error: Invalid layout of preloaded class</p> <p>JRE version: (7.0_45-b18) (build )</p> <p>Java VM: Java HotSpot(TM) 64-Bit Server VM (24.45-b08 mixed mode windows-amd64 compressed oops)</p> <p>Failed to write core dump. Minidumps are not enabled by default on client versions of Windows</p> <p>An error report file with more information is saved as: C:\Users\Administrator\Workspace\Present\Present\hs_err_pid2276.log</p> <p>If you would like to submit a bug report, please visit:</p> <p><a href="http://bugreport.sun.com/bugreport/crash.jsp" rel="nofollow">http://bugreport.sun.com/bugreport/crash.jsp</a></p> <p>how to fix it. help me please. And here is the code i try to run...</p> <pre><code>import Jama.Matrix; import Jama.QRDecomposition; public class LeastSquare { private final int N; // number of observations private final int degree; // degree of the polynomial regression private final Matrix beta; // the polynomial regression coefficients private double SSE; // sum of squares due to error private double SST; // total sum of squares public LeastSquare(double[] x, double[] y, int degree) { this.degree = degree; N = x.length; // build Vandermonde matrix double[][] vandermonde = new double[N][degree+1]; for (int i = 0; i &lt; N; i++) { for (int j = 0; j &lt;= degree; j++) { vandermonde[i][j] = Math.pow(x[i], j); } } Matrix X = new Matrix(vandermonde); // create matrix from vector Matrix Y = new Matrix(y, N); // find least squares solution QRDecomposition qr = new QRDecomposition(X); beta = qr.solve(Y); // mean of y[] values double sum = 0.0; for (int i = 0; i &lt; N; i++) sum += y[i]; double mean = sum / N; // total variation to be accounted for for (int i = 0; i &lt; N; i++) { double dev = y[i] - mean; SST += dev*dev; } // variation not accounted for Matrix residuals = X.times(beta).minus(Y); SSE = residuals.norm2() * residuals.norm2(); } public double beta(int j) { return beta.get(j, 0); } public int degree() { return degree; } public double R2() { if (SST == 0.0) return 1.0; // constant function return 1.0 - SSE/SST; } public double predict(double x) { // horner's method double y = 0.0; for (int j = degree; j &gt;= 0; j--) y = beta(j) + (x * y); return y; } public String toString() { String s = ""; int j = degree; // ignoring leading zero coefficients while (j &gt;= 0 &amp;&amp; Math.abs(beta(j)) &lt; 1E-5) j--; // create remaining terms for (j = j; j &gt;= 0; j--) { if (j == 0) s += String.format("%.2f ", beta(j)); else if (j == 1) s += String.format("%.2f N + ", beta(j)); else s += String.format("%.2f N^%d + ", beta(j), j); } return s + " (R^2 = " + String.format("%.3f", R2()) + ")"; } public static void main(String[] args) { double[] x = { 10, 20, 40, 80, 160, 200 };// double[] y = { 100, 350, 1500, 6700, 20160, 40000 }; LeastSquare regression = new LeastSquare(x, y, 3); System.out.println(regression); } </code></pre> <p>}</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload