How can i produce multi point linear interpolation? [closed] - math

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I have a linear interpolation methods. This is calculate interpolate value when (x1,y1) (x2,y2) and x0 known. it is calculate y0 value. But i need the do that when multi point known.
I am not talking about Bilinear or Trilinear interpolation.

For multi point interpolation there are 3 options:
piecewise linear interpolation
choose 2 closest points to your known coordinate if you use parameter then select the points containing parameter range and change the parameter range/scale to interpolation range (usually <0,1>) and interpolate as linear interpolation.
example of linear DDA on integers and more is in here:
Precise subpixel line drawing algorithm (rasterization algorithm)
polynomial interpolation
this is not linear !!! Take all known points, compute n-th degree polynomial from it (by Lagrange polynomial or by edge conditions or by regression/curve fitting or by whatever else) and compute the point from parameter as function of this polynomial. Usually you have one polynomial per axis the more the points and or degree of polynomial the less stable the result (oscillations).
piecewise polynomial interpolation
It is combination of #1,#2 (n is low to avoid oscillations). You need to call the point sequence properly to manage continuity between segments, the edge conditions must take into account previous and next segment...
here Piecewise interpolation cubic example
here How to construct own interpolation 3th degree polynomial
here How to construct own interpolation 4th degree polynomial
here point call sequence and BEZIER cubic as interpolation cubic
[notes]
SPLINE,BEZIER,... are approximation curves not interpolation (they do not necessarily cross the control points). There is a way how to convert in-between different types of curves by recomputation of control points. For example see this:
Interpolation cubic vs. Bezier cubic

Related

Formulating the exponential equation given a certain pair of points

I have the following pairs of points:
(0 , 100) ; (0.81 , 41) ; (1.38 , 20) ; (1.75 , 9) ; (2 , 4)
How can I determine the equation of the curve passing through this points?
Thanks very much!
UPDATE
What I'm trying to achieve is to get the function representative of the height decrease depicted in the picture.
There are infinitely many curves passing through these points. You have to be more specific.
If you want the minimal degree polynomial that passes through them you can use Lagrange interpolation polynomial.
With your example it would be a polynomial of degree 4.
But as I said if you allow for higher degrees you would get infinitely many results.
You can use lots of representations, depending on your requirements for continuity at each point.
Piecewise linear segments will "work", but you could also go with higher order piecewise interpolations. You could use Bezier or some other splining technique.
You could assume a single polynomial of order 4 and calculate the coefficients so it passed through each point.
There are lots of ways to do it.
If your data is x_i,y_i (i=1..n) you could fit a line through x_i,log(y_i); if that line is log(y_i) ~ a*x_i + b, then x->exp(b)*exp(a*x) may well fit the original data.
I found this website which seems to be precisely what I need. I just have to input my data pairs and choose the appropriate degree (in my case 4). It then compute the correlation factor and the equation.
http://www.arachnoid.com/polysolve/index.html

How do I calculate amplitude and phase angle of fft() output from real-valued input? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I have 24 samples from a real-valued signal. I perform the fft() function on the sample and get the complex output. I want to obtain the amplitude and phase angle of each of the non-redundant harmonics. I know my calculation must account for aliasing since I have real-valued data. How do I:
(1) convert from the two-sided to a one-sided Fourier transform,
I've heard several things here. For example, do I multiply the first 12 harmonics (i.e., 2nd through 13th elements of fft() output) by two and drop the rest of the harmonics (i.e., keep 1st through 13th elements of fft() output)?
(2) calculate the amplitude of the one-sided Fourier transform,
I know I can use the Mod() function, but when do I do this? Before or after I convert from two- to one-sided?
(3) calculate the phase angle of the one-sided Fourier transform.
I know I can use the atan() function on the ratio of imaginary to real parts of the fft() output, but again, when do I do this? Before or after two- to one-sided conversion? Also, what if atan is undefined?
Thanks.
Since your input is real the output of the FFT will be symmetric about N / 2 so you can just look at the first N / 2 bins and scale the magnitude by a factor of 2. For the phase you ideally need an atan2 function which takes the real and imaginary components as separate arguments and returns a 4 quadrant result.

What does correlation coefficient actually represent [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
What does correlation coefficient intuitively mean? If I have a series of X and then a series of Y, and if I input these two into Weka multilayer perceptron treating Y as the output and X as input, I get a correlation coefficient as 0.76. What does this intuitively represent, and how I explain this to a business man or a non-techie person?
There are several correlation coefficients. The most commonly used, and the one that is referred to as "the one" is Pearson's product moment correlation.
A correlation coefficient shows the degree of linear dependence of x and y. In other words, the coefficient shows how close two variables lie along a line.
If the coefficient is equal to 1 or -1, all the points lie along a line. If the correlation coefficient is equal to zero, there is no linear relation between x and y. however, this does not necessarily mean that there is no relation at all between the two variables. There could e.g. be a non-linear relation.
A positive relationship means that the two variables move into the same direction. A higher value of x corresponds to higher values of y, and vice versa.
A negative relationship means that the two variables move into the opposite directions. A lower value of x corresponds to higher values of y, and vice versa.
Here you have a handful of examples:

Calculation of tangents for cardinal spline curves

I am reading an article about about cubic Hermite interpolation. In the cardinal spline curve section they give a formula to calculate tangents at end points given by:
Ti = a * ( Pi+1 - Pi-1 )
However, if I have two points P1 and P2 then to find T1
T1 = a*(P2-P0).
I need to calculate this but what should be my P0 point be? Similarly to find T2 I will need to know P3. Can anyone clarify this?
You're right, this formula only makes sense for inner points in your spline which have neighbours on both sides. For endpoints you have to get the tangent from other constraints. The common solutions are:
supply manually chosen tangent points
choose the tangent such that the curvature at the endpoint is zero, this is referred to as natural boundary condition
choose periodic boundary conditions, that is, the tangents of the start- and endpoint are equal. Then you only have to specify one of the tangents. For a closed spline, you can get the last tangent from the natural boundary condition.
These ideas are brought up in the context of cubic splines, which require to solve a system of linear equations in order to get the polynomial coefficients for any part of the spline, because they minimize the total curvature of the whole spline, but in your case of Hermite splines they should be applicable, too.

How to make sure if a polynomial curve is monotonic under interval [a,b]?

If I got a polynomial curve, and I want to find all monotonic curve segments and corresponding intervals by programming.
What's the best way to do this...
I want to avoid solving equation like f'(x) = 0;
Using some nice numerical ways to do this,like bi-section, is preferred.
f'(x) expression is available.
Thanks.
Add additional details. For example, I get a curve in 2d space, and its polynomial is
x: f(t)
y: g(t)
t is [0,1]
So, if I want to get its monotonic curve segment, I must know the position of t where its tangent vector is (1,0).
One direct way to resolve this is to setup an equation "f'(x) = 0".
But I want to use the most efficient way to do this.
For example, I try to use recursive ways to find this.
Divide the range [0,1] to four parts, and check whether the four tangents projection on vector (1,0) are in same direction, and two points are close enough. If not, continue to divide the range into 4 parts, until they are in same direction in (1,0) and (0,1), and close enough.
I think you will have to find the roots of f'(x) using a numerical method (feel free to implement any root-seeking algorithm you want, Wikipedia has a list). The roots will be those points where the gradient reaches zero; say x1, x2, x3.
You then have a set of intervals (-inf, x1) (x1, x2) etc, continuity of a polynomial ensures that the gradient will be always positive or always negative between a particular pair of points.
So evaluating the gradient sign at a point within each interval will tell you whether that interval is monotically increasing or not. If you don't care for a "strictly" increasing section, you could patch together adjacent intervals which have positive gradient (as a point of inflection will show up as one of the f'(x)=0 roots).
As an alternative to computing the roots of f', you can also use Sturm Sequences.
They allow counting the number of roots (here, the roots of f') in an interval.
The monotic curve segments are delimited by the roots of f'(x). You can find the roots by using an iterative algorithm like Newton's method.

Resources