Re: [R] Find Crossover Points of Two Spline Functions

2015-09-28 Thread Ben Bolker
Bert Gunter gmail.com> writes: > > Use ?uniroot to do it numerically instead of polyroot()? > > Cheers, > Bert > Bert Gunter The problem with uniroot() is that we don't know how many intersections/ roots we might be looking for. With polyroot(), we know that there can be at most 3 roots that

Re: [R] Find Crossover Points of Two Spline Functions

2015-09-28 Thread Bert Gunter
... (should have added) However one might ask: Isn't this just a bit silly? The density() function gives kernel density estimates (perhaps interpolated by ?approx -- see ?density) on as fine a grid as one likes, so why use splines thereafter? And since these are density estimates -- i.e. fitted ap

Re: [R] Find Crossover Points of Two Spline Functions

2015-09-28 Thread Bert Gunter
Use ?uniroot to do it numerically instead of polyroot()? Cheers, Bert Bert Gunter "Data is not information. Information is not knowledge. And knowledge is certainly not wisdom." -- Clifford Stoll On Mon, Sep 28, 2015 at 9:17 AM, Ben Bolker wrote: > Dario Strbenac uni.sydney.edu.au> writes:

Re: [R] Find Crossover Points of Two Spline Functions

2015-09-28 Thread Ben Bolker
Dario Strbenac uni.sydney.edu.au> writes: > > Good day, > > I have two probability densities, each with a function determined > by splinefun(densityResult[['x']], > densityResult[['y']], "natural"), where densityResult is the > output of the density function in stats. > How can I determine all

[R] Find Crossover Points of Two Spline Functions

2015-09-28 Thread Dario Strbenac
Good day, I have two probability densities, each with a function determined by splinefun(densityResult[['x']], densityResult[['y']], "natural"), where densityResult is the output of the density function in stats. How can I determine all of the x values at which the densities cross ? --