1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
|
# 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
|