Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Week two assignment #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

tjagnyaseni3
Copy link

Week two assignment.

Description

Submission of week two assignment showing data plot fit with a linear and a cubic fit.

Weekly Journal

Based on the BIC both the fits are almost identical.

Questions

  • Question1

Week two assignment.
plt.subplot(2,1,1)
plt.scatter(x,y)
fit_1 = np.polyfit(x,y,1)
fit_lin = np.poly1d(fit_1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The assignment requests that you use the curve fit function to fit the cubic. It shouldn't be too difficult, so could you go back and change this to use that function?

#plt.title('x-y curve with Cubic Fit')

# Compute the area using the composite Simpson's rule.
area_s = simps(y, dx=0.5)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! You could also use the quad function. This uses Gaussian Quadrature and works on functions.

h_Linear = BIC(y,fit_lin(x),2) # for 1st order there are two coefficients
print("h_Linear=",h_Linear)

h_Cubic = BIC(y,fit_cubic(x),4) # 4 coefiicients for order 3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like you caught on to the error I made in recitation, that cubic has 4 parameters, not 3

Copy link
Contributor

@bencomer bencomer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see my comment on using the curve fit function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants