Bivariate Analysis#
Bivariate statistical tools.
elbow detection in an (x,y) plot
peaks: finding peaks, quantifying their height, width, center, area, left & right boundaries
area under curve
- process_improve.bivariate.methods.find_elbow_point(x, y, max_iter=41)[source]#
Find the elbow point when plotting numeric entries in x vs numeric values in list y.
Return the index into the vectors x and y [the vectors must have the same length], where the elbow point occurs.
Using a robust linear fit, sorts the samples in X (independent variable) and takes sample 1:5 from the left, and samples (end-5):end and fits two linear regressions, then computes the intersection of the two fitted lines. Adds a point to each regression, so (1:6) and (end-6:end) and repeats, accumulating one intersection point per iteration.
The elbow is taken as the data point whose (x, y) location is closest to the median of the accumulated intersection points; the median location is where the intersections should stabilise.
Will probably not work well on few data points. If so, try fitting a spline to the raw data and then repeat with the interpolated data.
- process_improve.bivariate.methods.find_line_intersection(m1, b1, m2, b2)[source]#
Find the intersection point of two lines.
From Stackoverflow: stackoverflow.com/questions/20677795/how-do-i-compute-the-intersection-point-of-two-lines
Returns a tuple: (x, y) where the two lines intersect, given slopes m1 and m2, and intercepts b1 and b2.