Let x and y be column vectors describing the vertices of a polygon, given in ord
ID: 3110879 • Letter: L
Question
Let x and y be column vectors describing the vertices of a polygon, given in order. Write functions polyperim (x, y) and polyarea (x, y) that compute the perimeter and area of the polygon. For the area, use a formula based on Green's theorem: A = 1/2 |sigma^n_k = 1 x_k y_k + 1 - x_k + 1 y_k|. Here n is the number of polygon vertices, and by definition, x_n + 1 = x_1 and y_n + 1 = y_1. Test your functions on a square and an equilateral triangle. Suppose a data source produces a series of characters drawn from a set of M distinct symbols. If symbol k is produced with probability pk, the first-order entropy of the source is defined as H_1 = - sigma^M _k = 1 pk log_2 pk. Essentially H_1 is the number of bits needed per symbol to encode a long message: that is, it measures the amount of information content, and therefore the potential success of compression strategies. The value H_1 = 0 corresponds to the case of only one symbol being produced - no information -while if all M symbols have equal probability, then H_1 = log_2 M. Write a function [H, M] = entropy (v) that computes entropy for a vector v. The probabilities should be computed empirically by finding the unique entries (using unique), then counting the occurrences of each symbol and dividing by the length of v. Try your function on some built - in image data by entering load clown, v = X (:);.Explanation / Answer
(3.4)-
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.