Home > Software design >  How to invert the estimate of a function with multiple inputs, but only invert the function for a si
How to invert the estimate of a function with multiple inputs, but only invert the function for a si

Time:03-31

I am trying to invert a function like one would invert an empirical cdf. If I wanted to invert an empirical cdf, I would write something like,

tau = 0.8
y=rnorm(1000,1)
[f,x]=ecdf(y)
q = interp1(f,x,tau,'next');

Instead, suppose that I have defined a function with multiple inputs, where all but the last input is based upon data. For example,

example_data= example_data_missingdatacdf(x1,x2,x3,scalar_delta)

I want to find the smallest value of delta such that

example_data_missingdatacdf(x1,x2,x3,scalar_delta)>= tau

What can I do? Thanks for any help in advance.

CodePudding user response:

You would find the value of scalar_delta for which example_data_missingdatacdf(x1,x2,x3,scalar_delta) - tau = 0. Assuming the function is monotonously increasing, this is the smallest value that satisfies your requirement.

There are standard numerical techniques to find the zero crossing of a function. MATLAB implements such a technique in fzero.

This is how you’d use it:

fun = @(d) example_data_missingdatacdf(x1,x2,x3,d) - tau;
scalar_delta = fzero(fun, 0);

The 0 is the start point for the algorithm, your best guess. Given that the function is monotonic, it is not important to have a good guess, you will always find the only zero. But a good guess will make the algorithm converge faster.

  • Related