/*! This file is auto-generated */ .wp-block-button__link{color:#fff;background-color:#32373c;border-radius:9999px;box-shadow:none;text-decoration:none;padding:calc(.667em + 2px) calc(1.333em + 2px);font-size:1.125em}.wp-block-file__button{background:#32373c;color:#fff;text-decoration:none} Q21E Mean and median. One of the most... [FREE SOLUTION] | 91Ó°ÊÓ

91Ó°ÊÓ

Mean and median. One of the most basic tasks in statistics is to summarize a set of observations x1,x2,…,xn⊆R by a single number. Two popular choices for this summary statistic are:

• The median, which we’ll callμ1

• The mean, which we’ll callμ2

(a) Show that the median is the value of μthat minimizes the function

∑i|xi-μ|

You can assume for simplicity that is odd. (Hint: Show that for any , the function decreases if you move either slightly to the left or slightly to the right.)

(b) Show that the mean is the value of μ that minimizes the function

∑i(xi-μ)2

One way to do this is by calculus. Another method is to prove that for any μ∈R,

∑i(xi-μ)2=∑i(xi-μ2)2+n(μ-μ2)2

Notice how the function for μ2 penalizes points that are far from much more heavily than the function for μ1 . Thus μ2 tries much harder to be close to all the observations. This might sound like a good thing at some level, but it is statistically undesirable because just a few outliers can severely throw off the estimate of μ2 . It is therefore sometimes said that μ1 is a more robust estimator than μ2 . Worse than either of them, however, is μ∞ , the value of μthat minimizes the function

maxi|xi-μ|

(c) Show that μ∞ can be computed in O(n) time (assuming the numbers are xismall enough that basic arithmetic operations on them take unit time).

Short Answer

Expert verified
  1. It can be shown that the median is the value of μ that minimizes the function ∑ixi-μ.
  2. It can be shown that the median is the value of μ that minimizes the function ∑ixi-μ2.
  3. Yes, the μ∞can be computed in O (n) time.

Step by step solution

01

Explain Mean and Median

Mean is the average of all the numbers divided by the total number of the numbers counted. Median is the middle value of the list of the numbers counted for median.

02

Step 2: Show that the median is the value of   that minimizes the given function

(a)

Consider that theμ'≠μ1.From the context of a sorted array, there are either more elements to the left μ' or to the right. Modify μ' to be the element to the right or left , one of the option makes the function described smaller.

If μ'is moved to the element to the left of it by the amount K. This makes the net difference to the function must either go up or down because μ'shifted K away from either more or less elements than it shifted K closer to.

By symmetry, Apply this argument to shifting to the right. One of these shifts must increase the function, and the other shift decrease the function.

Therefore, distinctly minimizes the function.

03

Step 3: Show that the mean is the value of  μ that minimizes the ∑i(xi-μ)2 function

(b) Consider the given function and expand it accordingly.

∑inxi-μ2=∑inxi-μ2+μ-μ22=∑inxi-μ22+2xi-μ2μ-μ2+μ-μ22=∑in(xi-μ2)2+n(μ-μ2)2+2(μ-μ2)∑in(xi)-²Ôμ2=∑in(xi-μ2)2+n(μ-μ2)2

Therefore, the given function can be minimized as above.

04

Step 4: Show that μ∞  can be computed in O(n)  time

(c)

Consider that the numbers xi are small that the basic arithmetic operations take unit time.

The μ∞,can be computed as follows.

μ∞=min(xi)+(max(xi)-min(xi))2

The above computation takes the O(n) time since the basic arithmetic operations in the computation takes unit time.

Unlock Step-by-Step Solutions & Ace Your Exams!

  • Full Textbook Solutions

    Get detailed explanations and key concepts

  • Unlimited Al creation

    Al flashcards, explanations, exams and more...

  • Ads-free access

    To over 500 millions flashcards

  • Money-back guarantee

    We refund you if you fail your exam.

Over 30 million students worldwide already upgrade their learning with 91Ó°ÊÓ!

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Most popular questions from this chapter

The Fibonacci numbers F0,F1,F2,... are defined by the rule

F0=0,F1=1,Fn=Fn−1+Fn−2.

In this problem we will confirm that this sequence grows exponentially fast and obtain some bounds on its growth.

(a) Use induction to prove that Fn≥20.5nfor n≥6.

(b) Find a constant c<1such thatFn≥2cn for all n≥0. Show that your answer is correct.

(c) What is the largestc you can find for which Fn=Ω(2cn)?

Is there a faster way to compute the nth Fibonacci number than by fib2 (page 4)? One idea involves matrices.

We start by writing the equations F1=F1 and F2=F0+F1 in matrix notation:


role="math" localid="1659767046297" (F1F2)=(0111).(F0F1).

Similarly,

F2F3=(0111).(F1F2)=(0111)2.(F0F1)

And in general

(FnFn+1)=(0111)n.(F0F1)

So, in order to compute Fn, it suffices to raise this 2×2 matrix, call it X, to the nth power.

a. Show that two 2×2matrices can be multiplied using 4additions and 8multiplications.

But how many matrix multiplications does it take to compute Xn?

b. Show that O(logn) matrix multiplications suffice for computing Xn. (Hint: Think about computing X8.)

Thus, the number of arithmetic operations needed by our matrix-based algorithm, call it fib3, is just O(logn), as compared to O(n)for fib2. Have we broken another exponential barrier? The catch is that our new algorithm involves multiplication, not just addition; and multiplications of large numbers are slower than additions. We have already seen that, when the complexity of arithmetic operations is taken into account, the running time offib2becomes O(n).

c. Show that all intermediate results of fib3 are O(n) bits long.


d. Let M(n)be the running time of an algorithm for multiplying n-bit numbers, and assume that M(n)=O(n2) (the school method for multiplication, recalled in Chapter 1, achieves this). Prove that the running time of fib3 is O(M(n)logn).


e. Can you prove that the running time of fib3 is O(M(n))? Assume M(n)=Θ(na)for some 1≤a≤2. (Hint: The lengths of the numbers being multiplied get doubled with every squaring.)


In conclusion, whether fib3 is faster than fib2 depends on whether we can multiply n-bit integers faster thanO(n2) . Do you think this is possible? (The answer is in Chapter 2.) Finally, there is a formula for the Fibonacci numbers:

role="math" localid="1659768125292" Fn=15(1+52)n−15(1−52)n.

So, it would appear that we only need to raise a couple of numbers to the nth power in order to computeFn . The problem is that these numbers are irrational, and computing them to sufficient accuracy is nontrivial. In fact, our matrix method fib3 can be seen as a roundabout way of raising these irrational numbers to the nth power. If you know your linear algebra, you should see why. (Hint: What are the eigenvalues of the matrix X?)

How long does the recursive multiplication algorithm (page 25) take to multiply an n -bit number by an m -bit number? Justify your answer.

A vertex cover of a graph G=(V,E)is a subset of vertices S⊆Vthat includes at least one endpoint of every edge in E. Give a linear-time algorithm for the following task.

Input: An undirected tree T=(V,E).

Output: The size of the smallest vertex cover of T. For instance, in the following tree, possible vertex covers include{A,B,C,D,E,F,G}and{A,C,D,F}but not{C,E,F}.The smallest vertex cover has size 3: {B,E,G}.

The tramp steamer problem. You are the owner of a steamship that can apply between a group of port cities V . You make money at each port: a visit to city i earns you a profit of pi dollars. Meanwhile, the transportation cost from port i to port j is cij>0 .You want to find a cyclic route in which the ratio of profit to cost is maximized.

To this end, consider a directed graph G=(V,E) whose nodes are ports, and which has edges between each pair of ports. For any cycle C in this graph, the profit-to-cost ratio is

role="math" localid="1658920675878" r(c)=∑i,jicPij∑i,jicCij

Let r' be the maximum ratio achievable by a simple cycle. One way to determine r' is by binary search: by first guessing some ratio r , and then testing whether it is too large or too small. Consider any positive r>0 . Give each edge (i,j) a weight of wij=rcij-pj .

  1. Show that if there is a cycle of negative weight, then .
  2. Show that if all cycles in the graph have strictly positive weight, then r<r*.
  3. Give an efficient algorithm that takes as input a desired accuracy ∈>0 and returns a simple cycle c for which r(C)3r*-∈ Justify the correctness of your algorithm and analyze its running time in terms of |V|,∈ and R=max(i,j)iE(PJCIJ) .
See all solutions

Recommended explanations on Computer Science Textbooks

View all explanations

What do you think about this solution?

We value your feedback to improve our textbook solutions.

Study anywhere. Anytime. Across all devices.