module Bayesnet::Parsers::Bif::ProbabilityContent2

Public Instance Methods

cpt() click to toggle source
# File lib/bayesnet/parsers/bif.rb, line 1106
def cpt
   distributions = list.elements.select { |e| e.respond_to?(:given) }.map do |e|
     {given: e.given,
      distribution: e.distribution}
   end
   table = list.elements.select { |e| e.respond_to?(:table) }.map do |e|
    {table: e.table}
   end
   if distributions.empty? && !table.empty?
     return table.first
   elsif !distributions.empty? && table.empty?
     return distributions
   elsif distributions.empty? && table.empty?
     raise "Either distributions or table must be provided"
   else
     raise "Both - distributions or table cannot be provided at the same time"
   end
end