06-26-2017 12:21 PM
Hi,
I have a 1D binary array. How am I supposed to fit it to a step function?
Attached is the waveform of the array.
Many thanks
Solved! Go to Solution.
06-26-2017 01:28 PM
Define a Step Function (so we know precisely what you mean). Note that you've shown something that is 0 up to some time, then is 1 for some time, then 0, then 1, etc. This can be constructed by a series of Step functions (where my definition is a function, Step(t, t0), that is 0 for t<t0, and is 1 for t>= t0). To get a pulse that goes up at t1 and down at t2, just add Step(t, t1) to -Step(t, t2). To get the next pulse, add Step(t, t3) - Step(t, t4), and so on.
For a Binary Array, the index of the Array elements is "t", True is 1, False is 0.
Bob Schor
06-26-2017 01:39 PM
The problem with step functions is that the partial derivatives with respect to the "x-shift" parameter will not work, because x is quantized to the measurements positions and shifting by a fractional value of less than the point spacing will no change the chisquare.
Please attach some typical data. Since your data is binary, all you can get out of it are the indices if the T>F and F>T positions. Is that what you want?
06-26-2017 01:55 PM
Dear Bob,
Thanks for your answer. What you are saying is that I generate a function that fits the data (correct me if I'm wrong). But what I'm looking for is that the computer can give me the intervals (of time in our case) where y values are 1. Is it possible to do that?
Rosh
06-26-2017 02:04 PM
@Rosh_Liu wrote:
Is it possible to do that?
Yes, it is possible. What have you tried?
Do you want the duty cycle?
06-26-2017 02:19 PM
I have tried the search all indices for a value in 1D array. But I would love know about your thoughts on the duty cycle since it feels right. Thanks very much!
06-26-2017 02:32 PM - edited 06-26-2017 02:33 PM
Since you are graphing (0,1) and not booleans, all you need is to sum all array elements and divide by the array size. This will give you the fraction of TRUE elements. Make sure that your datatype is sufficient to hold the sum (e.g. use I32)
06-26-2017 02:34 PM
Thanks very much. I won't mark it as solution since I kinda asked the questions weirdly that the discussions didn't answer the question. But anway, problem solved!
06-26-2017 02:37 PM - edited 06-26-2017 02:38 PM
Of course there are infinitely more parameters that could be extracted from the data, e.g. the average pulse spacing, pulse width, jitter in spacing and width, etc.
For the duty cycle mentioned earlier, you should also trim the data e.g. at the rising edges of the last and first pulse, else the result could be slightly off.