In this problem you are provided some raw data. You need to find a way of summarising the data with just a few parameters, so that it can be reconstructed. You then need to provide a handle to your own (generic) custom function that will indeed reproduce the raw data when provided with the parameters that you determine.
Consider a non-linear scalar function y = mˣ + c. Suppose x is the vector [3 2 1 4]. The function would operate elementwise on x; for example, if m=2 and c=3 then y = [11 7 5 19]. You are provided with both the vector x and the vector y. Every number will be provided in some form of an integer data type. The scalar parameters m and c are both whole numbers (although they're not provided directly).
So here you should output two things:
As the parameters will be used in your own function, the data type will be set by you.
So, for the above example, you could return a function handle @myFunc that you have defined, along with the variable param that has two fields such that param.base = 2 and param.translation = 3.
Or, if you have defined your function differently, then you could return the function handle @myFn along with a cell array variable prms that has four elements such that prms{1}='positive', prms{2}=uint8(3), prms{3} = 'positive' and prms{4} = uint8(2).
And so on.
Note 1: the parameter m can be assumed to have values between -30 and +30 (inclusive); the parameter c can be assumed to have values between -10000 and +10000 (inclusive); the elements in x are positive.
Note 2: if the code runs too slowly, then it will also fail the Test Suite.
Note 3: there might not be only one unique pair of the m & c parameter values that is correct — the individual values of m & c are not tested here, only the values of y that they predict are examined.
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.
20 Solvers
542 Solvers
Criss_Cross_000 : Unique elements in a Square array
9 Solvers
Find the elements of a matrix according to a defined property.
58 Solvers
Create logical matrix with a specific row and column sums
113 Solvers