Ich habe ein Codierungsproblem, wo ich Werte (x und y) plotten und die lineare Regression berechnen und in imageJ plotten möchte. Kann jemand helfen?Gibt es eine Möglichkeit, lineare Regression in ImageJ grafisch darzustellen?
Ich habe versucht, diese
public class Plot implements PlugIn {
public void run(String arg) {
if (IJ.versionLessThan("1.27t"))
return;
float[] x = {0.375f, 0.75f, 1.5f, 2.25f, 3f,3.75f,4.5f,4.75f,5f};
// x-coordinates
float[] y = {123f,456f,5678f,4567f,4567f,5678f,2345f,4563f,2345f};
// y-coordinates
float[] e = {.8f,.6f,.5f,.4f,.3f,.5f,.6f,.7f,.8f};
// error bars
PlotWindow plot = new PlotWindow("Example Plot","x-axis","y-axis",x,y);
plot.setLimits(0, 5.5, 0, 6000);
plot.addErrorBars(e);
// add a second curve
float x2[] = {.4f,.5f,.6f,.7f,.8f};
float y2[] = {4,3,3,4,5};
int N=9;
double sumx = 0.0, sumy = 0.0, sumx2 = 0.0;
for (int i = 0; i < N; i++)
sumx += x[i];
for (int i = 0; i < N; i++)
sumx2 += x[i]*x[i];
for (int i = 0; i < N; i++)
sumy += y[i];
double xbar = sumx/N;
double ybar = sumy/N;
// second pass: compute summary statistics
double xxbar = 0.0, yybar = 0.0, xybar = 0.0;
for (int i = 0; i < N; i++) {
xxbar += (x[i] - xbar) * (x[i] - xbar);
yybar += (y[i] - ybar) * (y[i] - ybar);
xybar += (x[i] - xbar) * (y[i] - ybar);
}
slope = xybar/xxbar;
intercept = ybar - slope * xbar;
// more statistical analysis
double rss = 0.0; // residual sum of squares
double ssr = 0.0; // regression sum of squares
for (int i = 0; i < N; i++) {
double fit = slope*x[i] + intercept; //calculating fit
rss += (fit - y[i]) * (fit - y[i]);
ssr += (fit - ybar) * (fit - ybar); //calculating ssr
}
}
}
Was funktioniert nicht? Wie geht es diesem Code nicht, was Sie erwarten? – jessehouwing