Question

The coefficients a and b of the line y = ax + b for the least squares fit of the n points (xi , yi) satisfy

i=1 2

Exercise 1: Express the cost to compute a and b as O(f(n)), for some function f. Justify your formula for f(n)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

\sum_{i=1}^{n}x_i  is the expression to calculate the mean of x.

The mean is calculate by calculating the sum of all terms in the set divided by the number of elements in the set.

So, the time complexities are:

  • T\left ( \sum_{i=1}^{n}x_i \right )=O(n)
  • T\left ( \sum_{i=1}^{n}x_i y_i \right )=O(n)
  • T\left ( \sum_{i=1}^{n}x_i^2 \right )=O(n)
  • T\left ( \left ( \sum_{i=1}^{n}x_i^2 \right )\left ( \sum_{i=1}^{n}x_i^2 \right ) \right )=O(n*n)=O(n^2)

So,

Time Complexity of a = T\left ( \sum_{i=1}^{n}x_i y_i \right )+T\left ( \left ( \sum_{i=1}^{n}x_i^2 \right )\left ( \sum_{i=1}^{n}x_i^2 \right ) \right )+T\left ( \sum_{i=1}^{n}x_i^2 \right )+T\left ( \sum_{i=1}^{n}x_i \right )

=O(n)+O(n^2)+O(n)+O(n)

=O(n^2)

Time Complexity of b = T\left ( \sum_{i=1}^{n}y_i \right )+T\left ( \sum_{i=1}^{n}x_i \right )

=O(n)+O(n)

=O(n)   

Add a comment
Know the answer?
Add Answer to:
The coefficients a and b of the line y = ax + b for the least...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT