Examples of BayesianError


Examples of org.encog.ml.bayesian.BayesianError

  }
 
  public RandomVariable requireEvent(String label) {
    RandomVariable result = this.map.get(label);
    if( result==null ) {
      throw new BayesianError("The variable " + label + " is not defined.");
    }
    return result;
  }
View Full Code Here

Examples of org.encog.ml.bayesian.BayesianError

   * @param result The resulting probability.
   * @param args The arguments.
   */
  public void addLine(double prob, int result, int... args) {
    if (args.length != this.event.getParents().size()) {
      throw new BayesianError("Truth table line with " + args.length
          + ", specied for event with "
          + this.event.getParents().size()
          + " parents.  These numbers must be the same");
    }

    TableLine line = findLine(result, args);

    if (line == null) {
      if (this.lines.size() == this.getMaxLines()) {
        throw new BayesianError("This truth table is already full.");
      }

      line = new TableLine(prob, result, args);
      this.lines.add(line);
    } else {
View Full Code Here

Examples of org.encog.ml.bayesian.BayesianError

  /**
   * Validate the truth table.
   */
  public void validate() {
    if (this.lines.size() != this.getMaxLines()) {
      throw new BayesianError("Truth table for " + this.event.toString()
          + " only has " + this.lines
          + " line(s), should have " + this.getMaxLines()
          + " line(s).");
    }

View Full Code Here

Examples of org.encog.ml.bayesian.BayesianError

          return line.getResult();
        }
      }
    }

    throw new BayesianError("Incomplete logic table for event: "
        + this.event.toString());
  }
View Full Code Here

Examples of org.encog.ml.bayesian.BayesianError

    try {
      fis = new FileInputStream(f);
      return readBIF(fis);
    } catch (IOException ex) {
      throw new BayesianError(ex);
    } finally {
      if (fis != null) {
        try {
          fis.close();
        } catch (IOException ex) {
View Full Code Here

Examples of org.encog.ml.bayesian.BayesianError

      SAXParserFactory spf = SAXParserFactory.newInstance();
      SAXParser sp = spf.newSAXParser();
      sp.parse(is, h);
      return h.getNetwork();
    } catch (IOException ex) {
      throw new BayesianError(ex);
    } catch (ParserConfigurationException ex) {
      throw new BayesianError(ex);
    } catch (SAXException ex) {
      throw new BayesianError(ex);
    }
  }
View Full Code Here

Examples of org.encog.ml.bayesian.BayesianError

    FileOutputStream fos = null;
    try {
      fos = new FileOutputStream(file);
      writeBIF(fos, network);
    } catch (IOException ex) {
      throw new BayesianError(ex);
    } finally {
      if (fos != null) {
        try {
          fos.close();
        } catch (IOException e) {
View Full Code Here

Examples of org.encog.ml.bayesian.BayesianError

  /**
   * @return The child events.
   */
  public ParsedEvent getChildEvent() {
    if( this.baseEvents.size()>1 ) {
      throw new BayesianError("Only one base event may be used to define a probability, i.e. P(a), not P(a,b).");
    }
   
    if( this.baseEvents.size()==0) {
      throw new BayesianError("At least one event must be provided, i.e. P() or P(|a,b,c) is not allowed.");
    }
   
    return this.baseEvents.get(0);
  }
View Full Code Here

Examples of org.encog.ml.bayesian.BayesianError

              parser.advance();
              parser.eatWhiteSpace();
              double min = Double.parseDouble(parser.readToWhiteSpace());
              parser.eatWhiteSpace();
              if(!parser.lookAhead("to", true) ) {
                throw new BayesianError("Expected \"to\" in probability choice range.");
              }
              parser.advance(2);
              double max = CSVFormat.EG_FORMAT.parse(parser.readToChars(",]"));
              parsedEvent.getList().add(new ParsedChoice(labelName,min,max));
             
View Full Code Here

Examples of org.encog.ml.bayesian.BayesianError

      addEvents(parser, result.getGivenEvents(), ",)=[]");

    }

    if (parser.peek() != ')') {
      throw new BayesianError("Probability not properly terminated.");
    }

    return result;
 
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.