Question: use only python to code KL divergence: We showed in class that for PMFs p and q defined on X', D(pl|9) > 0, D(9||p) E

 use only python to code KL divergence: We showed in class

use only python to code

KL divergence: We showed in class that for PMFs p and q defined on X', D(pl|9) > 0, D(9||p) E D(pl|9). This problem explores these properties experimentally. (a) Write a function that accepts as input two PMFs p and q as input, and outputs D(pl|9). (1) (b) As discussed in class, let p ~ Bern(r) and q ~ Bern(s). For a fixed value of r, vary s and do the following: (4) i. Plot D(pl|9), D(q||p). ii. Verify that D(pl|9), D(9||p) are indeed non-negative. iii. Verify that D(pl|9) + D(q|p) and are both equal to zero only when r = s. iv. Finally, find D (p119) and D(9|lp) where p and q are the normalized histograms of left.png and right.png respectively. Do you think D(pl|9) is a good metric for image similarity? Print your response. KL divergence: We showed in class that for PMFs p and q defined on X', D(pl|9) > 0, D(9||p) E D(pl|9). This problem explores these properties experimentally. (a) Write a function that accepts as input two PMFs p and q as input, and outputs D(pl|9). (1) (b) As discussed in class, let p ~ Bern(r) and q ~ Bern(s). For a fixed value of r, vary s and do the following: (4) i. Plot D(pl|9), D(q||p). ii. Verify that D(pl|9), D(9||p) are indeed non-negative. iii. Verify that D(pl|9) + D(q|p) and are both equal to zero only when r = s. iv. Finally, find D (p119) and D(9|lp) where p and q are the normalized histograms of left.png and right.png respectively. Do you think D(pl|9) is a good metric for image similarity? Print your response

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!