3
$\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$
  • $\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
  • $\begingroup$ Instead of treating this as a black box regression problem, it would be more informative to model the underlying physical system--resistive heating, heat transfer from the diode to the surrounding air, etc. $\endgroup$ – user20160 Oct 14 '19 at 14:38
1
$\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$
  • $\begingroup$ Interesting thoughts! How would you write such a model? $\endgroup$ – Dave Oct 14 '19 at 14:23
  • $\begingroup$ First, implement functions is_max(t) and is_min(t). Use these to segment the time interval into periods when it is increasing, and periods when it is decreasing. Then rebase each period to start at t=0, and plot them. To the eye it looks like you could validly average all the periods of decrease to produce a consensus curve, and all the periods of increase except the first. Then the task is to model each consensus curve. $\endgroup$ – chrishmorris Oct 16 '19 at 6:44
  • $\begingroup$ If this is right, I then suggest plotting dy/dt against t for each consensus curve. This drops out the additive constant, and I think will make the right model obvious. $\endgroup$ – chrishmorris Oct 16 '19 at 6:52

Your Answer

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