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

How to prevent poor fitting #111

Open
dsandber opened this issue Sep 11, 2023 · 4 comments
Open

How to prevent poor fitting #111

dsandber opened this issue Sep 11, 2023 · 4 comments

Comments

@dsandber
Copy link

dsandber commented Sep 11, 2023

The image below shows a fit I got using pwlf. Adjacent linear segments are shown in alternating colors for easy visualization. The blue dots are the original data points.

Is this issue not enough points in that region? Any suggestions on how to improve this?

image

Thanks!

@cjekel
Copy link
Owner

cjekel commented Sep 12, 2023 via email

@dsandber
Copy link
Author

dsandber commented Sep 12, 2023

The knot-points are fixed, so there's no optimisation if I'm understanding you right. The knot points have to be fixed because I'm optimising for an absurdly CPU constrained microcontroller. There's 128 segments. Seems like I should first fit a curve somehow, and then use pwlf after that once the data is continuous. Any suggestions for what to use to fit the curve? The underlying curve is very smooth with only slow changes in slope.

Update: Seems I want a smoothing spline. And then I'll feed that to PWLF.

@cjekel
Copy link
Owner

cjekel commented Sep 13, 2023 via email

@dsandber
Copy link
Author

dsandber commented Sep 13, 2023

In the process of making an example for you I realised I had a bug that was causing the issue, however after fixing it there's still a problem.

I have 256 data points and 129 knots. I've attached an example with the data as a json. Running it should open the graphs in a browser. Seems like the gaps are causing an issue even though there's more data points than segments.

The graphs look like:

image

data.txt
example.txt

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

No branches or pull requests

2 participants