aboutsummaryrefslogtreecommitdiff
path: root/beliefs/factors/bernoulli_or_cpd.py
diff options
context:
space:
mode:
authorCathy Yeh <cathy@driver.xyz>2017-12-11 18:56:15 -0800
committerCathy Yeh <cathy@driver.xyz>2017-12-11 18:56:15 -0800
commit65d822247e30b6e104a8c09d3b930487b9f20a58 (patch)
treed44b83f001ab352b30e17ab981295c2ee70a4d56 /beliefs/factors/bernoulli_or_cpd.py
parent26b43410569044aff46053cae7c68862825dd4ec (diff)
parent7b5c17c316481edbbd13815390d0b34fb50a03a6 (diff)
downloadbeliefs-65d822247e30b6e104a8c09d3b930487b9f20a58.tar.gz
beliefs-65d822247e30b6e104a8c09d3b930487b9f20a58.tar.bz2
beliefs-65d822247e30b6e104a8c09d3b930487b9f20a58.zip
LGS-173 Merge branch 'bernoulli_and_node'v0.0.3
Diffstat (limited to 'beliefs/factors/bernoulli_or_cpd.py')
-rw-r--r--beliefs/factors/bernoulli_or_cpd.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/beliefs/factors/bernoulli_or_cpd.py b/beliefs/factors/bernoulli_or_cpd.py
index bfb3a95..12ee2f6 100644
--- a/beliefs/factors/bernoulli_or_cpd.py
+++ b/beliefs/factors/bernoulli_or_cpd.py
@@ -21,11 +21,11 @@ class BernoulliOrCPD(TabularCPD):
parents=parents,
parents_card=[2]*len(parents),
values=[])
- self._values = []
+ self._values = None
@property
def values(self):
- if not any(self._values):
+ if self._values is None:
self._values = self._build_kwise_values_array(len(self.variables))
self._values = self._values.reshape(self.cardinality)
return self._values
@@ -37,6 +37,9 @@ class BernoulliOrCPD(TabularCPD):
if k == 1:
return np.array([0.5, 0.5])
+ # values are stored as a row vector using an ordering such that
+ # the right-most variables as defined in [variable].extend(parents)
+ # cycle through their values the fastest.
return np.array(
[1.,] + [0.]*(2**(k-1)-1) + [0.,] + [1.]*(2**(k-1)-1)
)