Asked by Kris Hoffman
on 7 Dec 2018 at 20:20

Just tried running a test.

gX = randi(100,10,1,'gpuArray');

gY = randi(100,10,1,'gpuArray');

[a,b] = fit(gX,gY,'exp1');

gather(a,b);

and all I get is the error...

LSQCURVEFIT requires the following inputs to be of data type double: 'X0','YDATA'.

Is there any way to run 'fit' on the GPU (GTX 1080)?

Thanks.

Answer by Joss Knight
on 8 Dec 2018 at 19:28

Accepted Answer

No, there isn't, but other options may be adaptable to your problem.

Kris Hoffman
on 8 Dec 2018 at 20:55

Will this become a feature in future iterations of MATLAB?

Sign in to comment.

Answer by Joss Knight
on 9 Dec 2018 at 19:23

Kris Hoffman
on 10 Dec 2018 at 23:18

Agreed, I know it's a shotgun approach (pardon), but I'm just trying to get similar numbers between the two functions (fit , polyfit). Also, for less variablility, because I also know 10 points is soo few, I've added a couple more zeros.

Question: In 'fit', what does the output 'b' represent?

FIT_b_exp1 =

General model Exp1:

FIT_b_exp1(x) = a*exp(b*x)

Coefficients (with 95% confidence bounds):

a = 49.94 (42.58, 57.29)

b = -0.0004671 (-0.003049, 0.002115)

Kris Hoffman
on 10 Dec 2018 at 23:35

Oh sorry, I see what it is. It's been a long day heh.

Walter Roberson
on 11 Dec 2018 at 18:51

A lot of the time, but not necessarily in this case, when you see a fit with a range of potential values that crosses 0, such as (-0.003049, 0.002115), then what it can mean is that the results are effectively nonsense, that it was not able to decide between alternate solutions within error bounds.

You are only fitting one exponential in this case. If you were fitting the sum of two or more exponentials or (even more so) two or more guassians, then that kind of situation would probably show up. In such cases, it is common for the algorithm to pick one of the terms as being the "right" term and to try to fit it exactly while treating the other terms as effectively noise, but which of the terms gets lucky depends upon the initial condition (which is often random). The algorithm does not deliberately do this: it is just how the math works out if you do not happen to start with initial conditions in the Goldilocks Zone.

In cases that involve coefficients to an even power, then unless bounds conditions are put in place, fitting cannot tell the difference between the negative and the positive value for the coefficient; in such cases you would see an output in which negative and positive bounds are close to equal but opposite in sign (but often not exactly equal.)

Seeing outputs with confidence bounds that cross 0 should be a warning flag to check the results more carefully.

Sign in to comment.

Opportunities for recent engineering grads.

Apply Today
## 0 Comments

Sign in to comment.