Author Topic: Help,How can I get the value of Beta distribution  (Read 14766 times)

Offline phpafstdio

  • Newbie
  • *
  • Posts: 6
    • View Profile
Help,How can I get the value of Beta distribution
« on: November 02, 2012, 04:46:32 »
I want to get the value of a Beta distribution,but I don't know how to do.please tell me how to do. and if it is convenient, give me an example.Thank you!
« Last Edit: November 02, 2012, 09:33:25 by Anders L Madsen »

Offline Anders L Madsen

  • HUGIN Expert
  • Hero Member
  • *****
  • Posts: 2295
    • View Profile
Re: Help,How can I get the value of Beta distribution
« Reply #1 on: November 02, 2012, 09:35:12 »
You can find examples on how to construct expressions for numeric nodes in the manual:
http://download.hugin.com/webdocs/manuals/Java/

For instance, this example:
http://download.hugin.com/webdocs/manuals/Java/COM/hugin/HAPI/package-summary.html#Example%203

Alternatively, you can use the code wizard in the HUGIN GUI to generate an example as this:
Code: [Select]
//Auto-generated JAVA code from HUGIN (double precision, table generator: true)

public static COM.hugin.HAPI.Domain createDomain() throws ExceptionHugin {
    //temporary variables
    COM.hugin.HAPI.Table t;
    COM.hugin.HAPI.Model model;
    COM.hugin.HAPI.ParseListener p = new COM.hugin.HAPI.DefaultClassParseListener();
    COM.hugin.HAPI.NodeList nodeList;

    //instantiate
    COM.hugin.HAPI.Domain domain = new COM.hugin.HAPI.Domain();

    COM.hugin.HAPI.IntervalDCNode node_C3 = new COM.hugin.HAPI.IntervalDCNode(domain);
    node_C3.setName("C3");
    node_C3.setNumberOfStates(10);
    node_C3.setStateLabel(0, "0 - 0.1");
    node_C3.setStateValue(0, 0.0);
    node_C3.setStateLabel(1, "0.1 - 0.2");
    node_C3.setStateValue(1, 0.1);
    node_C3.setStateLabel(2, "0.2 - 0.3");
    node_C3.setStateValue(2, 0.2);
    node_C3.setStateLabel(3, "0.3 - 0.4");
    node_C3.setStateValue(3, 0.3);
    node_C3.setStateLabel(4, "0.4 - 0.5");
    node_C3.setStateValue(4, 0.4);
    node_C3.setStateLabel(5, "0.5 - 0.6");
    node_C3.setStateValue(5, 0.5);
    node_C3.setStateLabel(6, "0.6 - 0.7");
    node_C3.setStateValue(6, 0.6);
    node_C3.setStateLabel(7, "0.7 - 0.8");
    node_C3.setStateValue(7, 0.7);
    node_C3.setStateLabel(8, "0.8 - 0.9");
    node_C3.setStateValue(8, 0.8);
    node_C3.setStateLabel(9, "0.9 - 1");
    node_C3.setStateValue(9, 0.9);
    node_C3.setStateValue(10, 1.0);

    COM.hugin.HAPI.NumberedDCNode node_C2 = new COM.hugin.HAPI.NumberedDCNode(domain);
    node_C2.setName("C2");
    node_C2.setNumberOfStates(3);
    node_C2.setStateLabel(0, "1");
    node_C2.setStateValue(0, 1.0);
    node_C2.setStateLabel(1, "2");
    node_C2.setStateValue(1, 2.0);
    node_C2.setStateLabel(2, "3");
    node_C2.setStateValue(2, 3.0);

    COM.hugin.HAPI.NumberedDCNode node_C1 = new COM.hugin.HAPI.NumberedDCNode(domain);
    node_C1.setName("C1");
    node_C1.setNumberOfStates(2);
    node_C1.setStateLabel(0, "1");
    node_C1.setStateValue(0, 1.0);
    node_C1.setStateLabel(1, "2");
    node_C1.setStateValue(1, 2.0);

    //structure
    node_C3.addParent(node_C1);
    node_C3.addParent(node_C2);

    //parameters
    nodeList = new COM.hugin.HAPI.NodeList();
    model = new Model(node_C3, nodeList);
    model.setExpression(0, "Beta (C1, C2)", p);

    t = node_C2.getTable();
    {
        double[] data = new double[]{0.3333333333333333,0.3333333333333333,0.3333333333333333};
        t.setData(data, 0, 3);
    }

    t = node_C1.getTable();
    {
        double[] data = new double[]{0.5,0.5};
        t.setData(data, 0, 2);
    }

    //triangulate
    nodeList = new COM.hugin.HAPI.NodeList();
    nodeList.add(node_C1);
    nodeList.add(node_C2);
    nodeList.add(node_C3);
    domain.triangulate(nodeList);

    return domain;
}

« Last Edit: November 02, 2012, 10:09:14 by Anders L Madsen »
HUGIN EXPERT A/S

Offline phpafstdio

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Help,How can I get the value of Beta distribution
« Reply #2 on: November 02, 2012, 13:56:21 »
Thank you very much for answer my question.