Question: Write a Prolog program to solve the problem described above. Define a predicate medical_test(+PatientData, -ProbDPos1, -ProbDPos2, -ProbHNeg1, -ProbHNeg2, -Best) . PatientData is a nonempty list
Write a Prolog program to solve the problem described above.
Define a predicate medical_test(+PatientData, -ProbDPos1, -ProbDPos2, -ProbHNeg1, -ProbHNeg2, -Best).
PatientData is a nonempty list of 4-element lists [PatientNum, HasDisease, PosOnTest1, PosOnTest2], where HasDisease is 1 if the patient has the disease, else 0 PosOnTest1 is 1 if the patient patient tested positive on test 1, else 0 PosOnTest2 is 1 if the patient patient tested positive on test 2, else 0
The predicate should always succeed. When it succeeds, ProbDPos1 is P(D | Pos1) ProbDPos2 is P(D | Pos2) ProbHNeg1 is P(H | Neg1) ProbHNeg2 is P(H | Neg2) Best is one of {test1, test2, neither}, indicating which test is better.
You may assume that the Patient_Data list will be in the correct format when the function is called, and that the list will be nonempty; you do not have to error-check for a non-list or an incorrectly formed list. In your program, you may write and call any additional predicates that are helpful in the computation.
Examples:
medical_test([ [1, 1, 1, 0], [2, 1, 1, 1], [3, 0, 0, 0], [4, 0, 0, 0], [5, 1, 1, 0], [6, 0, 0, 0], [7, 0, 0, 0], [8, 1, 0, 1], [9, 0, 1, 0], [10, 0, 0, 0] ], ProbDPos1, ProbDPos2, ProbHNeg1, ProbHNeg2, Best)
should succeed with
ProbDPos1 = .75 ProbDPos2 = 1 ProbHNeg1 = .83 ProbHNeg2 = .75 Best = neither
medical_test([ [1, 1, 0, 1], [2, 1, 1, 0], [3, 0, 0, 0], [4, 0, 0, 1], [5, 0, 0, 1], [6, 0, 0, 0], [7, 0, 0, 1], [8, 0, 1, 1] ], ProbDPos1, ProbDPos2, ProbHNeg1, ProbHNeg2, Best)
should succeed with
ProbDPos1 = .5 ProbDPos2 = .2 ProbHNeg1 = .83 ProbHNeg2 = .67 Best = test1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
