Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 0 pts . Write a python function to smooth your data with a moving average. The function should return an array that is the

10 pts. Write a python function to smooth your data with a moving average. The function
should return an array that is the moving average of an input array of data that contains
noise or errors in it.
10 pts. Write a python function to return an array that is the first derivative of an array
with respect to another array. The first input array is the independent variable. The
second input array is the dependent variable. The function should compute the derivative
using first order forward finite difference.
10 pts. Write a python function to return an array that is the first derivative of an array
with respect to another array. The first input array is the independent variable. The
second input array is the dependent variable. The function should compute the derivative
using second order central finite difference. Note: this second derivative function may be
the same as the previous one but using an optional input variable to select first order,
second order, or even 3rd,4th,dots, order (BONUS) accurate differencing.
10 pts. Each. Write a python script to use your functions to analyze data.
a. Implement python forms of the 1968 Mustang GT equations given on the class
slides for x,v, and a.
b. Get xNoisy=x+, where is random noise (e.g., numpy.random.rand(50)/50).
You may add noise to v and a to compare (v,noise and a,noise).
c. Use your smoothing function on xNoisy to get xsmth.
d. Use your differentiation functions on xNoisy and xsmth to compute vNoisy and
vsmth. Note that you will have 2 first derivatives for each order and a 2nd
order).
e. Use your differentiation functions on vNoisy and vsmth to compute aNoisy and
asmth. Note that you will again have 2 first derivatives for each order and a
2nd order).
f. Generate a figure with sub-plots of x,v, and a in three rows, respectively, with
one t horizontal axis. Note that there will be x,xNoisy and xsmth in the first sub-
plot. Note also that the second sub-plot will show v,1st order vNoisy and vsmth;
2nd order vNoisy and vsmth. Note also that the third sub-plot will show a,1st order
aNoisy and asmth;2nd order aNoisy and asmth. You can plot more if you wish, as
long as they are relevant.
g. Print (with nice statements, units, etc.) the mean square error (MSE) between
properties plotted, where
MSE(x)=1ni=1n(xi-xNoisy,i)2
That MSE is indeed like the variance between dependent variables and a good way to see how
close the curves, or kinematic properties, are. A statistics course is highly recommended to learn
more about MSE... A sample implementation of MSE is numpy.mean ((x-xNoisy)2).
Try different numbers of points (not just 50 but 100,1000,dots ). Try different equations. Have fun
w/this!
Note that the numerical differentiations will lead to arrays 1 element less than the array being
differentiated. You may choose to extrapolate to get the arrays to be the same length (using
material from a previous semester). Alternatively, you may choose to make sure to plot against a
t array with 1 less element.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Public Finance Fundamentals

Authors: K. Moeti

3rd Edition

148512946X, 9781485129462

Students also viewed these Databases questions