www.vorhilfe.de
Vorhilfe

Kostenlose Kommunikationsplattform für gegenseitige Hilfestellungen.
Hallo Gast!einloggen | registrieren ]
Startseite · Forum · Wissen · Kurse · Mitglieder · Team · Impressum
Forenbaum
^ Forenbaum
Status Vorhilfe
  Status Geisteswiss.
    Status Erdkunde
    Status Geschichte
    Status Jura
    Status Musik/Kunst
    Status Pädagogik
    Status Philosophie
    Status Politik/Wirtschaft
    Status Psychologie
    Status Religion
    Status Sozialwissenschaften
  Status Informatik
    Status Schule
    Status Hochschule
    Status Info-Training
    Status Wettbewerbe
    Status Praxis
    Status Internes IR
  Status Ingenieurwiss.
    Status Bauingenieurwesen
    Status Elektrotechnik
    Status Maschinenbau
    Status Materialwissenschaft
    Status Regelungstechnik
    Status Signaltheorie
    Status Sonstiges
    Status Technik
  Status Mathe
    Status Schulmathe
    Status Hochschulmathe
    Status Mathe-Vorkurse
    Status Mathe-Software
  Status Naturwiss.
    Status Astronomie
    Status Biologie
    Status Chemie
    Status Geowissenschaften
    Status Medizin
    Status Physik
    Status Sport
  Status Sonstiges / Diverses
  Status Sprachen
    Status Deutsch
    Status Englisch
    Status Französisch
    Status Griechisch
    Status Latein
    Status Russisch
    Status Spanisch
    Status Vorkurse
    Status Sonstiges (Sprachen)
  Status Neuerdings
  Status Internes VH
    Status Café VH
    Status Verbesserungen
    Status Benutzerbetreuung
    Status Plenum
    Status Datenbank-Forum
    Status Test-Forum
    Status Fragwürdige Inhalte
    Status VH e.V.

Gezeigt werden alle Foren bis zur Tiefe 2

Navigation
 Startseite...
 Neuerdings beta neu
 Forum...
 vorwissen...
 vorkurse...
 Werkzeuge...
 Nachhilfevermittlung beta...
 Online-Spiele beta
 Suchen
 Verein...
 Impressum
Das Projekt
Server und Internetanbindung werden durch Spenden finanziert.
Organisiert wird das Projekt von unserem Koordinatorenteam.
Hunderte Mitglieder helfen ehrenamtlich in unseren moderierten Foren.
Anbieter der Seite ist der gemeinnützige Verein "Vorhilfe.de e.V.".
Partnerseiten
Dt. Schulen im Ausland: Mathe-Seiten:

Open Source FunktionenplotterFunkyPlot: Kostenloser und quelloffener Funktionenplotter für Linux und andere Betriebssysteme
Forum "Softwaretechnik und Programmierung" - linearen Regression.
linearen Regression. < Softwaretechnik+Pro < Praktische Inform. < Hochschule < Informatik < Vorhilfe
Ansicht: [ geschachtelt ] | ^ Forum "Softwaretechnik und Programmierung"  | ^^ Alle Foren  | ^ Forenbaum  | Materialien

linearen Regression.: Frage (überfällig)
Status: (Frage) überfällig Status 
Datum: 11:17 Do 15.06.2006
Autor: ANjaan

Aufgabe
Erstellen Sie ein Programm in Java zur Berechnung der linearen Regression.


import java.io.*;
import java.util.*;

public class Regression
{
   public static void main (String [] args)
   {
      do
      {
         doRegression();
         System.out.println();
         System.out.print("Nochmal? (yes/no) : ");
      } while (read().equals("yes"));

   }

   public static void doRegression()
   {
      LinkedList<Double> xList = new LinkedList<Double>();
      LinkedList<Double> yList = new LinkedList<Double>();
      String currentValue = null;
      do
      {
         System.out.print("Bitte nächsten x-Wert eingeben : ");
         currentValue = read();
         if (currentValue.equals("")) break;
         double x = Double.parseDouble(currentValue);
         System.out.print("Bitte nächsten y-Wert eingeben : ");
         currentValue = read();
         if (currentValue.equals("")) break;
         double y = Double.parseDouble(currentValue);
         xList.add(x);
         yList.add(y);
      } while (!currentValue.equals(""));

      int count = xList.size();
      double [] xArray = new double [count];
      double [] yArray = new double [count];
      int i = 0;
      for (Double value : xList)
      {
         xArray[i] = value;
         ++i;
      }
      i = 0;
      for (Double value : yList)
      {
         yArray[i] = value;
         ++i;
      }

      double xSum = 0;
      double ySum = 0;
      for (i = 0 ; i < xArray.length ; ++i)
      {
         System.out.println ((i+1) + ". x = " + xArray[i] + " y = " + yArray[i]);
         xSum += xArray[i];
         ySum += yArray[i];
      }
      double xMean = xSum / (double)xArray.length;
      double yMean = ySum / (double)yArray.length;
      System.out.println ("x Durchschnitt : " + xMean);
      System.out.println ("y Durchschnitt : " + yMean);

      double b1 = 0;
      double b2 = 0;
      for (i = 0 ; i < xArray.length ; ++i)
      {
         b1 += xArray[i]*yArray[i];
         b2 += xArray[i]*xArray[i];
      }
      b1 -= ((double)xArray.length)*xMean*yMean;
      b2 -= ((double)xArray.length)*xMean*xMean;
      double b = b1 /b2;
      double a = yMean - b*xMean;
      System.out.println ("Geradengleichung : " + b + " * x + " + a);

      double sb1 = 0;
      double sb2 = 0;
      double sa1 = 0;
      for (i = 0 ; i < xArray.length ; ++i)
      {
         sb1 += (yArray[i] - b *xArray[i] - a) * (yArray[i] - b *xArray[i] - a);
         sb2 += (xArray[i] - xMean) * (xArray[i] - xMean);
         sa1 += xArray[i] * xArray[i];
      }
      double sb = sb1 / (((double)xArray.length - 2) * sb2);
      double sa = sb * sa1 / (double)xArray.length;
      sb = Math.sqrt(sb);
      sa = Math.sqrt(sa);
      System.out.println ("Standardabweichung der Steigung : " + sb);
      System.out.println ("Standardabweichung des y-Achsen-Abschnittes : " + sa);
   }

   public static String read()
   {
      try
      {
         BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
         return reader.readLine();
      }
      catch (IOException e)
      {
      }
      return null;
   }
}  

Ich kann meine Fehler nicht finden hier:

LinkedList<Double> xList = new LinkedList<Double>();

und bin stecken bleiben.

Bitte um Hilfe.

Danke im Voraus



        
Bezug
linearen Regression.: Fälligkeit abgelaufen
Status: (Mitteilung) Reaktion unnötig Status 
Datum: 11:20 Do 22.06.2006
Autor: matux

$MATUXTEXT(ueberfaellige_frage)
Bezug
Ansicht: [ geschachtelt ] | ^ Forum "Softwaretechnik und Programmierung"  | ^^ Alle Foren  | ^ Forenbaum  | Materialien


^ Seitenanfang ^
www.vorhilfe.de