pingspice.analysis.fixture.LumpinessCalculator(object)
class documentation
Part of pingspice.analysis.fixture
(View In Hierarchy)
Call an instance of me to obtain a scalar metric that indicates the "lumpiness" of a vector Y that transitions from a lower value to a higher value.
The metric is computed using the second derivative of Y, given the accompanying X vector. The values of Y can be all positive, all negative, or transition from negative to positive. Only the derivatives matter.
The value of the metric is zero for a smooth, non-reversing transition. That is achieved when the second derivative never goes from negative to positive.
The metric is proportional (nonlinearly) to the sum of slopes of all positive-going zero crossings of the second derivative ss.
If the clipping constructor keyword is set True
, the
metric also includes a term c times pr, the latter being the
ratio of negative 2nd-derivative peak to standard deviation of the
2nd-derivative, taken to power Nc.
With unity weight, the metric should be around one for a very lumpy vector, assuming there isn't clipping causing pr to be significant. The equation for the metric is:
metric = weight*((a*ss/(Y[-1]-Y[0]))^b + c*pr
where ss is the sum of slopes and Y[-1]-Y[0] is the total transition that Y makes over the interval, and pr = abs((min(ddY)-mp)/mp))^Nc and mp is the maximum positive peak of ddY, if any.
The metric is scaled down by the square of the number of lumps as that number starts to exceed fifteen or so. The idea is that a vector with tons of very tiny lumps isn't really lumpy at all, just slightly quantized.
Parameters | clipping | Set True to check clipping with by including the pr
term. |
Class Variable | Ns | The number of samples +/- k for the linear regression that
calculates the slopes in slope . |
Class Variable | Nc | The exponent for calculation of pr. |
Method | __init__ | Undocumented |
Method | find_zero_crossings_NP | Returns a list of indices of the supplied vector Y where the value is negative and the next value is positive. |
Method | zero_crossingerator | Yields 2-tuples, each with (1) an index of the supplied vector Y
at a zero crossing and (2) a bool that is True if the zero
crossing was negative-going. |
Method | find_next_peak | Returns a 2-tuple with (1) the sample distance to the right of index k and (2) the height of the next peak after k. |
Method | find_prev_peak | Returns a 2-tuple with (1) the sample distance to the left of index k and (2) the height of the previous peak before k. |
Method | slope | No summary |
Method | clipping | No summary |
Static Method | dydx | Undocumented |
Method | __call__ | Call my instance with an X vector and a corresponding vector Y of ascending values. |
Returns a list of indices of the supplied vector Y where the value is negative and the next value is positive.
Negative values within 10^-15 of zero are not considered negative.
Yields 2-tuples, each with (1) an index of the supplied vector Y
at a zero crossing and (2) a bool that is True
if the zero
crossing was negative-going.
Returns a 2-tuple with (1) the sample distance to the right of index k and (2) the height of the next peak after k.
Returns a 2-tuple with (1) the sample distance to the left of index k and (2) the height of the previous peak before k.
Returns the slope of Y vs X for the zero crossing at index k. Calculated from the difference between the adjacent negative and positive peaks divided by the distance between them.
Given the second derivative of the values ddY, returns the ratio, taken to exponent Nc, of the absolute value of the negative peak minus the standard deviation, divided by the standard deviation. If the absolute value of the negative peak is less than or equal to the standard deviation, the result is zero.
This is an indicator of an abrupt downward curvature, i.e., clipping.