I think you may need to modify some of the tests to "...ensure both odd and even values of x" in all cases where m might be negative.
Hi, Tim. Thanks for your feedback. Actually, from the Player's point of view, m 'could' be negative in any Test. I agree that in some situations there might not be one unique pair of the m & c parameter values that is correct. However, I never apply an assertion to the values of m & c in the Test Suite, rather I check what values of y the user-supplied parameters produce from the user-supplied function(handle). _Any_ valid combination of m & c should be able to REpredict the same values of y provided in the original input, from the same x values (or a subset thereof). There is only one test where I check for prediction of y using x values not included in the original input (extrapolation/interpolation), and for that one test I do have to be careful to ensure there is one unique pair of m & c values that is correct. So I would say this is intentional (I'll add a short note to the Problem Statement). But please let me know if there's a flaw in my logic. —DIV
Aha--I see now. To quote Emily Litella: "Never mind."
I should clarify one detail for other Players. Given y = mˣ + c (elementwise), suppose x is the vector [7 8 5 6] and y is the vector [123 123 123 123]. Then there are two valid combinations of m & c, namely m=0 & c=123 and m=1 & c=122. So actually there is not just one unique set of m & c values in this case. However, given x>0 (in the Problem Statement), either of these alternatives can be correctly extrapolated or interpolated from.
This solution fails sometimes, and I have no idea why (it's just a "smart" brute force code). I've tried to reproduce the error several times on my pc, but I wasn't able to. And I've even tried to use python's long to no avail . Probably I am underfitting at some cases, but it works sometimes. :)
3971 Solvers
594 Solvers
Arrange Vector in descending order
4091 Solvers
217 Solvers
77 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!