Author Topic: Creating Interval Node for Normal Distribution  (Read 16628 times)

Offline sandra

  • Newbie
  • *
  • Posts: 2
    • View Profile
Creating Interval Node for Normal Distribution
« on: May 18, 2010, 08:10:47 »
Just a quick easy question:

I am using the Java API to create a BN and I want to create an interval node which discretises a normal distribution with say mean 0.25 and variance 0.15.

I got as far as :

IntervalDCNode intNode = new IntervalDCNode (domain);
intNode.setNumberOfStates(10);


and then didn't know how to set the distribution and ranges that I want the intNode node to have.

I also don't know how to assign a normal distribution to a continuous node:

ContinuousChanceNode contNode = new ContinuousChanceNode(domain);

then what?? I expected there to be a method such as setDistribution(normal, mean, variance) - wishful thinking!

I looked at the Java examples and API documentation, but it is not clear to me how I create it.
The constructor needs two Expression objects, one for the mean & one for the variance, but don't know how to create the Expression objects to represent the mean & variance

Thanks.

Offline Anders L Madsen

  • HUGIN Expert
  • Hero Member
  • *****
  • Posts: 2295
    • View Profile
Re: Creating Interval Node for Normal Distribution
« Reply #1 on: May 18, 2010, 09:41:55 »
Hi Sandra,

Quote
I got as far as :
Code: [Select]
IntervalDCNode intNode = new IntervalDCNode (domain);
intNode.setNumberOfStates(10);
Quote
and then didn't know how to set the distribution and ranges that I want the intNode node to have.

You should use the method
Code: [Select]
setStateValue to define the intervals.  This discussion item describes how to create an expression that sums two numbered nodes:
http://forum.hugin.com/index.php?topic=111.0
The principle is the same for intervals nodes. Notice that HUGIN does not know how to identify the intervals, i.e., perform the discretization.

Quote
I also don't know how to assign a normal distribution to a continuous node:
Code: [Select]
ContinuousChanceNode contNode = new ContinuousChanceNode(domain);
Quote
then what??

By definition a continuous node has a Normal distribution. Thus, you should use
Code: [Select]
setAlpha
setBeta
setGamma
on ContinuousChanceNode to set the parameters of the distribution.

Hope this helps. If not, ask again:-)
HUGIN EXPERT A/S

Offline sandra

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Creating Interval Node for Normal Distribution
« Reply #2 on: May 19, 2010, 05:25:51 »
Great, thanks Anders.
Too easy!
Thanks for your quick response.
Cheers,
Sandra