0

I am fitting my data with a polynomial with curve_fit. I have forced the fit to go through certain data points, but I actually don't know what those points are.

If this is my fitting function:

popt, pcov = curve_fit(func3, xdata1, ydata1, p0=(1, 1, 1, 1), sigma=weight1)

where:

weight1[[list(range(42,113))+list(range(156, 197))+ list(range(2000, 1100))]] = 0.01

What do the values, 42, 156, and 2000 actually represent? The values, 113, 197, and 1100 seem to be the index of the X-values. Essentially I don't know what the first value for range stands for.

FChm
  • 2,515
  • 1
  • 17
  • 37
D.Kim
  • 151
  • 3
  • 10
  • Check out the documentation for [range](https://docs.python.org/3/library/stdtypes.html#range), that should help clarify at least part of your question. – FChm May 22 '19 at 12:49
  • Essentially I have index values that go up to 1100. For some reason, the first value in range can basically have any number. The second value only can go up to 1100. Doesn't make sense to me. – D.Kim May 22 '19 at 12:59
  • I suggest you read the documentation I linked, I think that should help clarify what range does. Try printing `list(range(2000,1100))` to see why your final use of range doesn't work. – FChm May 22 '19 at 13:02
  • The thing is that it does work! That is the weird part. My fit will change drastically depending on the first value of ""range". I don't have 2000 indices, so I have no clue why I don't get an error when I plug in 2000 in the range for the first value, but not for the second. – D.Kim May 23 '19 at 06:55

0 Answers0