[Numpy-discussion] Upper and lower envelopes
Tue Sep 30 08:01:41 CDT 2008
You can estimate the intercept and slope using least-squares
(scipy.optimize.leastsq). Make sure though that errors in X are small
compared to errors in Y, otherwise, your slope will be underestimated.
Using the slope, you can write a function lower(b,a, X,Y) that will compute
y=aX+b and return True if Y < y. Computing the ratio of true elements will
give you the percentage of points below the curve. You can then find b such
that the ratio is .5 and .95 using scipy.optimize.fmin.
There are other ways to do this;
Make a 2D histogram of the data (normed), compute the cumulative sum along Y
and find the histogram bins (along x) such that the cumulative histogram is
approximately equal to .5 and .95.
Partition the data in N sets along the x-axis, fit a normal distribution to
each set and compute the quantile corresponding to .5 and .95 cumulative
By the way, anonymous mails from newcomers don't get as much attention as
those that are signed. Call it mailing list etiquette.
On Tue, Sep 30, 2008 at 5:06 AM, bevan <firstname.lastname@example.org> wrote:
> I have some XY data. I would like to generate the equations for an upper
> lower envelope that excludes a percentage of the data points.
> I would like to define the slope of the envelope line (say 3) and then have
> code find the intercept that fits my requirements (say 5% of data below the
> lower envelope). This would then give me the equation and I could plot the
> upper and lower envelopes.
> I hope this makes sense. Thanks for any help.
> Numpy-discussion mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Numpy-discussion