MANE 3351 - Manufacturing Engineering Analysis
Laboratory 3 Assignment
Assigned: October 25, 2021
Due: October 28, 2021
Learning Goals
- Write user-defined scalar function in Python
- Convert user-defined scalar function to vectorized function in Python
Description
The purpose of this laboratory is the use of user-defined functions in Python.
For this lab you will write a function that evaluates the probability density function of the exponential pdf shown below.
where \(\lambda>0\) and \(x>0\). Your function will accept two parameters \(x\) and \(\lambda\) (lambda) and returns the value of \(f(x)\).
Step 1
Update your personal information in the first cell (Markdown).
Step 2
In cell 2 (Python cell), define the scalar function to return a single value of \(f(x)\) when provided the values of x and \(\lambda\) (lambda). Demonstrate your functions works by printing the results of running your function.
A helpful resource for this step is How to Create User-Defined Functions in Python.
Step 3
In cell 3 (Python cell), convert your scalar user-defined function into a vectorized function. A similar example was included in the lecture11_sep27 classroom Jupyter notebook. Apply the vectorized function to the array x provided in the code cell and print the results.
The reference material for a vectorized function is provided at numpy.vectorize.
Step 4
After completing steps 1-3, remember to push your local repository back to Dr. Timmer's master repository.