how to use noisy adder

The engine.
Post Reply
Jochen0x90h
Posts: 19
Joined: Thu Jul 11, 2013 1:20 pm

how to use noisy adder

Post by Jochen0x90h » Wed Aug 07, 2013 2:52 pm

I'd like to test the noisy adder, also known as noisy average in the thesis of zagorecki (Local Probability Distributions in Bayesian Networks: Knowledge Elicitation and Inference).

I use this code to create the pump example:

Code: Select all

Network network = new Network();
int pump = network.addNode(Network.NodeType.Cpt, "Pump");
network.setOutcomeId(pump, 0, "non_stop");
network.setOutcomeId(pump, 1, "failure");
network.addOutcome(pump, "ok"); // *

int crack = network.addNode(Network.NodeType.Cpt, "Crack");
network.setOutcomeId(crack, 0, "present");
network.setOutcomeId(crack, 1, "absent"); // *

int sensor = network.addNode(Network.NodeType.NoisyAdder, "Sensor");
network.setOutcomeId(sensor, 0, "high");
network.setOutcomeId(sensor, 1, "normal"); // *
network.setOutcomeId(sensor, 2, "low");

network.addArc(pump, sensor);
network.addArc(crack, sensor);

network.setNodeDefinition(pump, getP3(0));
network.setNodeDefinition(crack, getP2(1));

network.setNodeDefinition(sensor, new double[]{
		0.8, 0.1, 0.1, // nonstop, absent*
		0.05, 0.15, 0.8, // fail, absent*
		0.0, 1.0, 0.0, // ok*, absent*
		0.02, 0.08, 0.9, // ok*, present
		0.0, 1.0, 0.0, // ok*, absent*
		0.0, 1.0, 0.0, // leak
});

network.writeFile("pump.xdsl");
pump.xdsl looks like this:

Code: Select all

<?xml version="1.0" encoding="ISO-8859-1"?>
<smile version="1.0" id="Unnamed" numsamples="1000" discsamples="10000">
	<nodes>
		<cpt id="Pump">
			<state id="non_stop" />
			<state id="failure" />
			<state id="ok" />
			<probabilities>0 1 0</probabilities>
		</cpt>
		<cpt id="Crack">
			<state id="present" />
			<state id="absent" />
			<probabilities>1 0</probabilities>
		</cpt>
		<noisyadder id="Sensor">
			<state id="high" />
			<state id="normal" />
			<state id="low" />
			<parents>Pump Crack</parents>
			<dstates>1 2 1</dstates>
			<weights>1 1 1</weights>
			<parameters>0.3333333333333333 0.3333333333333333 0.3333333333333333 0.3333333333333333 0.3333333333333333 0.3333333333333333 0 1 0 0.3333333333333333 0.3333333333333333 0.3333333333333333 0 1 0 0 1 0</parameters>
		</noisyadder>
	</nodes>
</smile>
I wonder why the parameters are 0.3333333333333333?
What are <dstates> and how can I set them using the java api?

-Jochen

Post Reply