2
$\begingroup$

I can't figure out what type of regression analysis or extrapolation technique to use in order to come up with an equation for the data I have plotted.

For a school project, I've been testing diodes by connecting them to a temperature switch that shuts off the circuit once the temperature reaches around 250 degrees Celsius. I plotted the data, and I wanted to extrapolate it and get an equation that I could use to predict future diode temperatures. However, I have tried all sorts of extrapolation techniques and none of them accurately fits the data. For example

enter image description here

extrapolation1

as well as this:

enter image description here

extrapolation2

I've tried extrapolation/regressions in both R Studio and python, but I simply cannot get an accurate enough equation for either. Is there anything I could improve in my code, or maybe is there another technique I could use?

This is the code I used to get the first graph:

import numpy as np
import pandas as pd
from scipy.optimize import curve_fit

df = pd.read_csv("JB WELD DIODE REG.csv")
def func(x, a, b, c,d):
    return a*np.sin(b*x-c)+d
x = (df.time)/10**2
y= (df.diode)/10**2


popt, pcov = curve_fit(func, x, y)
popt


plt.plot(x, func(x, *popt), 'r-',
        label='fit: a=%5.3f, b=%5.3f, c=%5.3f, d=%5.3f' %tuple(popt)
        )
plt.plot(x, y)
$\endgroup$

migrated from stackoverflow.com Dec 26 '18 at 7:38

This question came from our site for professional and enthusiast programmers.

  • $\begingroup$ If you post a link to the data file, I can run the data through my Python open source "function finder" at zunzun.com and see what candidate equations it suggests. It has hundreds of known, named equations to search through. $\endgroup$ – James Phillips Dec 26 '18 at 11:20
  • 1
    $\begingroup$ What's on the X axis? Time? $\endgroup$ – HakunaMaData Dec 26 '18 at 12:55
  • 1
    $\begingroup$ Why doesn't the temperature fall all the way to room temperature.. is that because you're not letting the diode cool down? Also, Why did the temperature start from close to zero in the beginning? It is important as you could model this as noise and ignore parts of the curves. $\endgroup$ – HakunaMaData Dec 26 '18 at 13:02
0
$\begingroup$

There are clearly two different segments to each curve. I suggest fitting each separately.

While it is heating up, it looks exponential - see whether log(250-t) is linear.

While it is cooling down, it looks quadratic, so I suggest seeing whether sqrt(t-75) is linear.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy