Skip to content

Exercise Template

mboivin edited this page Oct 25, 2020 · 13 revisions

# Exercise 1 - Name of the exercise

|                         |                    |
| -----------------------:| ------------------ |
|   Turn-in directory:    |  ex00              |
|   Files to turn in:     |  *.py              |
|   Authorized modules:   |                    |
|   Forbidden modules:    |                    |
|   Forbidden functions:  |                    |
|   Remarks:              |  n/a               |

**Objective(s):**
Description of the objective(s) of the exercise.

**Instructions:**
In the *.py file create the following function(s) as per the instructions below:
```python
def func(param_name):
    """
    Description.
    Args:
      Arg1: has to be a [type], description...
    Returns:
      The return(s).
    Raises:
      This function shouldn't raise any Exception.
    """
```

**Examples:**
```python
print("Code example")
```

Objective(s):

If a formula is re-implemented, use the following template:


You must implement the following formula as a function:  
$$
formula as latex
$$

where:  
- $formula_param1$ is ...
- $formula_param2$ is ...

Instructions:

Inputs:

  • vectors or matrices of the functions must be numpy.ndarray
  • constant must be float

Outputs:

  • vectors or matrices of the functions must be numpy.ndarray
  • constant must be float
  • if inputs are invalid, must return None
Example of instruction:
def sum_(x, f):
    """Computes the sum of a non-empty numpy.ndarray onto wich a function is
applied element-wise, using a for-loop.
    Args:
      x: has to be an numpy.ndarray, a vector.
      f: has to be a function, a function to apply element-wise to the vector.
    Returns:
      The sum as a float.
      None if x is a non-empty numpy.ndarray or if f is not a valid function.
    Raises:
      This function should not raise any Exception.
    """

Examples:

  • At least 2 examples for each functions. If its behavior is complex do not hesitate to put more!
  • Do not show examples of invalid inputs.
  • Any time it is possible, show the official result (with Numpy, Sklearn) after the function example to show that it mimics properly the original one.