# AI代写/machine learning代写: Prob. Models for AI

AI代写/machine learning代写:这是一个典型的利用C++，涉及AI的基础程序代写，涉及算法代写等相关内容
Prob. Models for AI
Using the factor code you wrote for the third problem set, write code to perform variable elimination as in algorithm
9.1
Use this algorithm along to calculate the marginals over variable J and over the pair I-J, in the Bayesian network given below. This network is the same as the running example in the book, except that I (intelligence) has been replaced with T (test-taking ability) and I is now a parent of T, and H (happiness) has been removed.
CDTI GS
LJ
CPDs:
c0 c1 0.5 0.5
l1,s1
d0 d1 t0 t1 t0,d0 c0 0.4 0.6 i0 0.9 0.1 t0,d1 c1 0.8 0.2 i1 0.4 0.6 t1,d0
t1 ,d1 l0 l1
g1 g2 g3 0.3 0.4 0.3 0.05 0.25 0.7 0.9 0.08 0.02
0.5 0.3
0.2
j1 0.1
0.6 0.7 0.9
j0 l0,s0 0.9
s0 s1
0.6 0.4 t0 0.95 0.05 g2 0.4 0.6 l0,s1
i0 i1
g1 0.1 0.9
t1 0.2 0.8 g3 0.99 0.01 l1,s0
0.4 0.3 0.1
Your algorithm should have running time O ̃(nc) where n is the number of eliminated factors and c is the number of elements in the largest factor produced. Note that the key operation is step 1 of Sum-Product-Eliminate-Var. Doing it in O(n) time is not hard. Doing it in O(lg n) requires an index of some form. You may submit an algorithm that takes O ̃(n2c), but you will receive a maximum of 6 points.
Your code must be written in C++ and must implement the varelim method of the bn class given by bn.h and bn.cpp (supplied on iLearn with this assignment). The file vetest.cpp tests your code’s ability to find the marginal over J and the marginal over I & J in the network above.
Your assignment should run with the supplied factor.h and factor.cpp, which are solutions to the previous programming assignment. There is no need to change bn.h, so you should not submit a new version. Please do NOT submit any additional files.
To make grading easier, each question is its own “assignment” on gradescope. Submit your answers to problem 1 for assignment 4.1 and your code for problem 2 for assignment 4.2. For problem 4.2, submit only bn.cpp.