codesimian
Class ContinuousBayesNode

java.lang.Object
  extended by codesimian.CS<CSGeneric>
      extended by codesimian.DefaultCS
          extended by codesimian.BayesNode
              extended by codesimian.ContinuousBayesNode
All Implemented Interfaces:
CodeSimian
Direct Known Subclasses:
SimpleFastContinuousBayesNet

public class ContinuousBayesNode
extends BayesNode

continuousBayesNode(list(childs...) list(probabilities...)) returns the predicted value of its first child in the list.

If P(2) exists, it is the LEARNING SPEED, which ranges 0 - 1. Closer to 0 is best. If not, the default learning speed is used, approximately .05

CHANGE THE JAVADOC: Instead of predicting the last child, the FIRST child is predicted.

EXTERNAL TRAINING VS SELF TRAINING:
Similar to BayesNode, but modifies its own probability list (P(1)) by slowly averaging in child values. Every time this ContinuousBayesNode executes, it gets the values of its childs and slightly updates the probabilities. ContinuousBayesNode returns the PREDICTED value of the last child (P(1).P(P(1).countP()-1))

LIST SIZES:
Unlike a normal BayesNode, probability list's size must be 2^(child lists's size). A normal bayesnode has a probability list has size 2^(child lists's size + 1) because the normal bayesnode's probability is included as a child, but a continuousBayesNode does not predict its own value. Instead it predicts the value of continuousBayesNode.P(0).P(0).D() which must be between 0.0 and 1.

THIS CLASS SHOULD BE CHANGED TO PREDICT THE VALUE OF ITS FIRST CHILD INSTEAD OF THE LAST BECAUSE IN CODESIMIAN CODE YOU CAN USE 0 INSTEAD OF countP(x) AND REPLACING x WITH AN =P.


Nested Class Summary
 
Nested classes/interfaces inherited from class codesimian.BayesNode
BayesNode.VerifyCountP
 
Field Summary
static double defaultAverageErrorStart
           
static double defaultLearningSpeed
           
 
Fields inherited from class codesimian.BayesNode
TYPE
 
Fields inherited from class codesimian.CS
DESCRIPTION, END, EXECPROXY, HEAP, JAVACODE, MYFUEL, NAME, NEWINSTANCE, NULL, PARENT, PARSEPRIORITY, PREV, TESTER, THIS
 
Constructor Summary
ContinuousBayesNode()
           
 
Method Summary
 double averageError()
           
static void copyArrayToCS(double[] array, CS list)
           
 java.lang.String description()
          a short description of this CS, shorter than the javadoc, but long enough to tell what the params are for.
 double DForProxy()
          returns this node's CHANCE (0.0 to 1) based on the DForProxy()s/chances of param0's params and the conditional-probabilities in param1.
 java.lang.String keyword()
          For the CodeSimian language as a String.
CodeSimian language keyword, like "+" "*" "max" ">" etc.

Override this function if you want to specify a keyword other than how I derive them from the class name, like + for Add.

Some CSs might never be intended to be used in the language by their keyword.
The best example (4/05) is Num, because it is used in the language like "3.4" instead of "num()".
 int maxP()
          Maximum quantity of Params
 int minP()
          For DForProxy().
Minimum number of parameters in param[] needed to call DForProxy().
Defines which indexs of param[] DForProxy() can use.
Functions with a different number of parameters must override this.
OVERRIDE THIS FUNCTION IF EXEC USES A DIFFERENT NUMBER OF PARAMETERS.
Default is 1.
 boolean setD(double execValue)
          Removes all child bayes-nodes and all conditional-probabilities.
 
Methods inherited from class codesimian.BayesNode
addToHistory, adjustBitChance, bitChance, childCountForCondProbSize, cost, makeArraySumTo1, PType, sum
 
Methods inherited from class codesimian.DefaultCS
B, C, countP, decrementMyFuel, deleteP, F, fuel, getExec, getObject, heap, I, indexP, indexPName, insertB, insertC, insertD, insertF, insertI, insertJ, insertL, insertL, insertL1, insertP, insertS, insertZ, J, javaCode, LForProxy, LForProxy, myFuel, name, newInstance, objectToCS, objectToCSArray, objectToCSArray, P, prevD, prevL, S, setB, setC, setCountP, setD, setExec, setF, setFuel, setI, setJ, setL, setL, setL, setL1, setMyFuel, setName, setObject, setP, setPrevExec, setPType, setS, setZ, start, toString, V, Z
 
Methods inherited from class codesimian.CS
addB, addC, addD, addF, addI, addJ, addL, addP, addP, addP, addP, addP, addS, addZ, BForProxy, CForProxy, clone, D, deleteP, FForProxy, GETB, GETC, GETD, GETF, GETI, GETJ, GETL, GETS, GETZ, IForProxy, isIllusion, JForProxy, L, L, L, L, L, maxD, minD, overwrites, parent, parsePriority, PB, PC, PD, PF, PI, PJ, PL, prevB, prevC, prevF, prevI, prevJ, prevS, prevZ, proxyOf, PS, PZ, reflect, reflect, reflect6, setB, SETB, setC, SETC, setCost, SETD, setDescription, setF, SETF, setHeap, setI, SETI, setJ, SETJ, SETL, setL, setL, setParent, setParsePriority, setProxyOf, setS, SETS, setTester, setZ, SETZ, SForProxy, tester, toJavaCode, VForProxy, voidReflect, ZForProxy
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

defaultLearningSpeed

public static final double defaultLearningSpeed
See Also:
Constant Field Values

defaultAverageErrorStart

public static final double defaultAverageErrorStart
See Also:
Constant Field Values
Constructor Detail

ContinuousBayesNode

public ContinuousBayesNode()
Method Detail

averageError

public double averageError()

DForProxy

public double DForProxy()
Description copied from class: BayesNode
returns this node's CHANCE (0.0 to 1) based on the DForProxy()s/chances of param0's params and the conditional-probabilities in param1. DOES NOT DO THIS ANYMORE (7/05)... If there is a param2, then param2 is a history list, and DForProxy() saves DForProxy()'s returned value at the end of it.

Overrides:
DForProxy in class BayesNode

minP

public int minP()
Description copied from class: DefaultCS
For DForProxy().
Minimum number of parameters in param[] needed to call DForProxy().
Defines which indexs of param[] DForProxy() can use.
Functions with a different number of parameters must override this.
OVERRIDE THIS FUNCTION IF EXEC USES A DIFFERENT NUMBER OF PARAMETERS.
Default is 1.

Overrides:
minP in class BayesNode

maxP

public int maxP()
Description copied from class: CS
Maximum quantity of Params

Overrides:
maxP in class BayesNode

keyword

public java.lang.String keyword()
Description copied from class: DefaultCS
For the CodeSimian language as a String.
CodeSimian language keyword, like "+" "*" "max" ">" etc.

Override this function if you want to specify a keyword other than how I derive them from the class name, like + for Add.

Some CSs might never be intended to be used in the language by their keyword.
The best example (4/05) is Num, because it is used in the language like "3.4" instead of "num()".
Default: Returns class name, minus package name (and its dots), and change the first letter to lowercase.

For example, CS.MaxParams does not override keyword(), which returns "maxP".

Overrides:
keyword in class BayesNode
See Also:
CS.parent(), CS.newInstance(), CS.name()

description

public java.lang.String description()
Description copied from class: CS
a short description of this CS, shorter than the javadoc, but long enough to tell what the params are for. Example use: in automatically generated webpages for CodeSimian. Example: "returns sum of all params" for Add.

Overrides:
description in class BayesNode

setD

public boolean setD(double execValue)
Description copied from class: BayesNode
Removes all child bayes-nodes and all conditional-probabilities. Adds 2 conditional-probabilities. The normal bayes algorithm makes DForProxy() return the second value.

I PLAN TO DO THIS LATER, BUT ITS NOT YET IMPLEMENTED: Executes this BayesNode to determine its current value. Then adjusts the conditional-probabilities in param1 to make this node's DForProxy() return execShouldReturnThisValue (without damaging the other ratios). WARNING: executing this BayesNode could cause infinite loops because the caller might not know this function executes it and therefore did not setMyFuel(to some small number) yet.

Overrides:
setD in class BayesNode

copyArrayToCS

public static void copyArrayToCS(double[] array,
                                 CS list)