Hi all,
I'm new to Python (and to coding in general). If anyone can help out with the problem below or point me in the right direction I'd really appreciate it.
I have a noisy dataset through which I'd like to fit the best possible cubic polynomial using the least squares method. numpy.polyfit is almost what I want, but for physical reasons there are some additional constraints on the curve:
1. It should pass through the origin (0, 0) and
2. All of the coefficients should be non-negative.
Basically I want to fit a curve of the form
y = ax**3 + bx**2 + cx where a, b and c are all >= 0
Is there a way of using numpy.polyfit with these additional constraints, or is there another method entirely that's accessible to a relative beginner?
Thanks very much for any help or advice!
I'm new to Python (and to coding in general). If anyone can help out with the problem below or point me in the right direction I'd really appreciate it.
I have a noisy dataset through which I'd like to fit the best possible cubic polynomial using the least squares method. numpy.polyfit is almost what I want, but for physical reasons there are some additional constraints on the curve:
1. It should pass through the origin (0, 0) and
2. All of the coefficients should be non-negative.
Basically I want to fit a curve of the form
y = ax**3 + bx**2 + cx where a, b and c are all >= 0
Is there a way of using numpy.polyfit with these additional constraints, or is there another method entirely that's accessible to a relative beginner?
Thanks very much for any help or advice!
Comment