Package org.integratedmodelling.riskwiz.pfunction

Examples of org.integratedmodelling.riskwiz.pfunction.TabularCPD


    private void initializeUniformDistributions() {
        Set<BNNode> nodes = bnet.vertexSet();

        for (BNNode node : nodes) {
            if (node.getFunction() instanceof TabularCPD) {
                TabularCPD function = (TabularCPD) node.getFunction();
         
                DistTable dtable = new DistTable(
                        (DiscreteDomain) function.getDomain(),
                        function.getParentsDomains());

                dtable.setUniformDistributions();
                node.setProperty("distribution", dtable);
                node.setFunction(dtable.createCPF());
            }
View Full Code Here


    private void initializeDistributions(int virtualSamples) throws ParseException {
        Set<BNNode> nodes = bnet.vertexSet();

        for (BNNode node : nodes) {
            if (node.getFunction() instanceof TabularCPD) {
                TabularCPD function = (TabularCPD) node.getFunction();
                DistTable dtable = new DistTable(function, virtualSamples);

                node.setProperty("distribution", dtable);
                node.setFunction(dtable.createCPF());
            }
View Full Code Here

    public TabularCPD createCPF() {
        Vector<DiscreteDomain> pDomains = new Vector<DiscreteDomain>();

        pDomains.addAll(super.domainProduct);
        TabularCPD cpf = new TabularCPD(domain, pDomains);

        if (!isScalar) {
            int[] structureIterator = this.index2addr(0);
            boolean done = false;

            while (!done) {
                Dirichlet dist = getValue(structureIterator);

                for (int domIndex = 0; domIndex < domain.getOrder(); domIndex++) {
                    cpf.setValue(
                            TableFactory.getCptReference(domIndex,
                            structureIterator),
                            dist.getExpectedVal(domIndex));
                }
                done = this.addOne(structureIterator);
            }
        } else {
            Dirichlet dist = multiarray[0];

            for (int domIndex = 0; domIndex < domain.getOrder(); domIndex++) {
                cpf.setValue(domIndex, dist.getExpectedVal(domIndex));
            }
        }

        return cpf;
    }
View Full Code Here

        bn.addEdge(bnodeCloudy, bnodeSprinkler);
        bn.addEdge(bnodeSprinkler, bnodeWetGrass);
        bn.addEdge(bnodeRain, bnodeWetGrass);

        // this is simple
        TabularCPD table = (TabularCPD) bnodeCloudy.getFunction();

        table.setValue(0, 0.5);
        table.setValue(1, 0.5);

        // see image sprinkler.jpg to make sense out of the order
        // plus mind the rder of execution of connect() above
        table = (TabularCPD) bnodeSprinkler.getFunction();
        table.setValue(0, 0.1);
        table.setValue(1, 0.5);
        table.setValue(2, 0.9);
        table.setValue(3, 0.5);

        // see image sprinkler.jpg to make sense out of the order
        table = (TabularCPD) bnodeRain.getFunction();
        table.setValue(0, 0.8);
        table.setValue(1, 0.2);
        table.setValue(2, 0.2);
        table.setValue(3, 0.8);

        // see image sprinkler.jpg to make sense out of the order
        table = (TabularCPD) bnodeWetGrass.getFunction();
        table.setValue(0, 0.99);
        table.setValue(1, 0.9);
        table.setValue(2, 0.9);
        table.setValue(3, 0.0);
        table.setValue(4, .01);
        table.setValue(5, 0.1);
        table.setValue(6, 0.1);
        table.setValue(7, 1.0);

        // Rain.setEvidence(new DiscreteEvidence((Discrete)Rain.getDomain(),
        // "true"));;
        // WetGrass.setEvidence(new
        // DiscreteEvidence((Discrete)Sprinkler.getDomain(), "true"));;
View Full Code Here

        properties = new Hashtable();   
        domType = DomainType.labels;
    
        switch (nodeType) {
        case  probabilistic:
            this.function = new TabularCPD(dom, null);
            break;

        case  noisymax:
            this.function = new TabularCPD(dom, null);
            this.noisyT = new NoisyT(dom, null);
            break;

        case  deterministic:
            this.function = new TabularDetF(dom, null);
View Full Code Here

TOP

Related Classes of org.integratedmodelling.riskwiz.pfunction.TabularCPD

Copyright © 2018 www.massapicom. 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.