User Tools

Site Tools


gibson:teaching:fall-2014:math445:hw5

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
gibson:teaching:fall-2014:math445:hw5 [2014/10/13 12:48]
gibson
gibson:teaching:fall-2014:math445:hw5 [2014/10/14 12:39]
gibson
Line 3: Line 3:
 Main concept for this homework: the ''​for''​ loop. Main concept for this homework: the ''​for''​ loop.
  
-1. Write a function ''​mymean''​ that uses a ''​for''​ loop to compute the mean of the elements of its input vector. Test that it's correct by comparing ​to Matlab'​s built-in ''​mean''​ function on a random vector. ​+1. Write a function ''​mymean''​ that uses a ''​for''​ loop to compute the mean of the elements of its input vector, according ​to the formula
  
-2. Write a function ''​mystd''​ that uses a ''​for''​ loop to computes the standard deviation of the elements of its input vector. Test by comparison to Matlab'​s built-in ''​std''​ function on a random vector.+\begin{eqnarray*} 
 +\text{mean}(x) = \frac{1}{N} \sum_{i=1}^N x_i 
 +\end{eqnarray*} 
 + 
 +where N is the number of elements in the vector. Test that your code is correct by comparing to Matlab'​s built-in ''​mean''​ function on a random vector.  
 + 
 +2. Write a function ''​mystd''​ that uses a ''​for''​ loop to computes the standard deviation of the elements of its input vector.  
 +\begin{eqnarray*} 
 +\text{std dev}(x) = \sqrt{\frac{1}{N-1} \sum_{i=1}^N (x_i - \bar{x})^2 
 +\end{eqnarray*} 
 +where $\bar{x}$ is the mean of $x$. Test by comparison to Matlab'​s built-in ''​std''​ function on a random vector.
  
 3. Write a script that produces a 10 x 10 multiplication table whose first three lines are  3. Write a script that produces a 10 x 10 multiplication table whose first three lines are 
Line 37: Line 47:
  
 where //N// is the number of columns of //A//. If A is //M x N// and //B// is //N x P//, then //C// is //M x P//. If //A// and //B// do not have compatible dimensions, print an error message and return a //0 x 0// matrix. ​ where //N// is the number of columns of //A//. If A is //M x N// and //B// is //N x P//, then //C// is //M x P//. If //A// and //B// do not have compatible dimensions, print an error message and return a //0 x 0// matrix. ​
- 
    
gibson/teaching/fall-2014/math445/hw5.txt · Last modified: 2014/10/14 12:39 by gibson