Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Help with Interpolation of data based on given input


This question is answered.


Permlink Replies: 22 - Last Post: Nov 9, 2016 12:58 AM Last Post By: ann mariya Threads: [ Previous | Next ]
Bryan Ray

Posts: 31
Registered: 3/2/07
Help with Interpolation of data based on given input  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 25, 2014 9:46 AM
To image what I need, think about a hurricane. The winds are stronger towards the center of the storm and weaker as you go further from the center.

I am given the distance (in miles) from the center to reach the edge of the 34 knot, 50 knot and 64 knot winds. So the 34 knot winds will extend much further outward than the 64 knot winds.
Sometimes the max winds of the storm are less than 64 knots so the 64 knot extent will be 0.

Here's my attempt at the algorithm. Unfortunately I'm stuck.
The results I would like to get is give an input needed wind speed value, and the result would be the distance from the center in miles to get to that distance.
Any help would be greatly appreciated.
Regards,
Bryan

                                             //100kts          75 mi         100mi           250mi       //83kts Val
function TStorm.GetIntervalWindRadiusDistance(StormMaxWindSpeed, GivenDistTo64, GivenDistTo50, GivenDistTo34, NeededDistanceOfThisWind : Integer): Integer;
   {Expected result is a smaller result value for a higher NeededWindDistance (Highest winds closest to center) }
Const Delta3450 = 16; Delta5064 = 14;  Delta3464 = 30;
var
  KnotsIncreasePerMile : Double;
begin
   {Example: if needed Distance to 135 knots and the max winds are only 100 knots, then return 0}
  If NeededDistanceofThisWind > MaxWindSpeed then
    Result := 0
  else
  begin
    if NeededDistanceOfThisWind > 64 then
    begin
      KnotsIncreasePerMile := Delta5064 / (Abs(GivenDistTo64 - GivenDistTo50));
                               // 14             75               100        =25  = .56 miles per knot increase??
      Result := KnotsIncreasePerMile * NeededDistanceOfThisWind;
    end;
  //  if (NeededDistanceOfThisWind < 64) and (NeededDistanceOfThisWind > 50) then
 
  //  if NeededDistanceOfThisWind < 34 then
 
  end;
 
end;
 
Quentin Correll


Posts: 2,412
Registered: 12/1/99
Re: Help with Interpolation of data based on given input  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 25, 2014 10:48 AM   in response to: Bryan Ray in response to: Bryan Ray
Bryan,

I don't have a clue. <g>

However, I don't see anything in your approach to account for
atmospheric density of the storm area due to temperature. Or to the
actual "outside diameter" of the storm. Some hurricanes are only a few
miles in diameter while others can be hundreds of miles in diameter.

Very interesting problem.

--

Q

05/25/2014 10:44:35

1.19.1.372 [Q'sBrokenToolBar] [Running on TQ]

Bryan Ray

Posts: 31
Registered: 3/2/07
Re: Help with Interpolation of data based on given input  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 25, 2014 1:38 PM   in response to: Quentin Correll in response to: Quentin Correll
Quentin Correll wrote:
Bryan,

I don't have a clue. <g>

However, I don't see anything in your approach to account for
atmospheric density of the storm area due to temperature. Or to the
actual "outside diameter" of the storm. Some hurricanes are only a few
miles in diameter while others can be hundreds of miles in diameter.

Very interesting problem.

--

Q

05/25/2014 10:44:35

1.19.1.372 [Q'sBrokenToolBar] [Running on TQ]


Hello Q,
Thanks. I do understand there are some unknowns... however I am only looking for the best guess based on given data.
I do realize this approach is truly an approximation.
Regards,
Bryan
Peter Below

Posts: 1,227
Registered: 12/16/99
Re: Help with Interpolation of data based on given input  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 25, 2014 11:50 AM   in response to: Bryan Ray in response to: Bryan Ray
Bryan Ray wrote:

To image what I need, think about a hurricane. The winds are
stronger towards the center of the storm and weaker as you go further
from the center.

I am given the distance (in miles) from the center to reach the edge
of the 34 knot, 50 knot and 64 knot winds. So the 34 knot winds will
extend much further outward than the 64 knot winds. Sometimes the
max winds of the storm are less than 64 knots so the 64 knot extent
will be 0.

The problem is that the distance from the center for a given speed is
likely not a simple linear function.
You can of course interpolate between the two nearest speed values you
have to get a distance for a given wind speed, but how you interpolate
depends on the function that describes the relationship between
distance and wind speed. Is it "flat" enough to allow linear
interpolation between two values? Or are you better served by trying to
fit all the data points you have to a polynomial or other suitable
mathematical expression first, which you then use to calculate the new
points?

A bit of literature research is indicated before you can start to cut
some code here, in my opinion...

--
Peter Below (TeamB)

Bryan Ray

Posts: 31
Registered: 3/2/07
Re: Help with Interpolation of data based on given input  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 25, 2014 1:36 PM   in response to: Peter Below in response to: Peter Below
Peter Below wrote:
Bryan Ray wrote:

To image what I need, think about a hurricane. The winds are
stronger towards the center of the storm and weaker as you go further
from the center.

I am given the distance (in miles) from the center to reach the edge
of the 34 knot, 50 knot and 64 knot winds. So the 34 knot winds will
extend much further outward than the 64 knot winds. Sometimes the
max winds of the storm are less than 64 knots so the 64 knot extent
will be 0.

The problem is that the distance from the center for a given speed is
likely not a simple linear function.
You can of course interpolate between the two nearest speed values you
have to get a distance for a given wind speed, but how you interpolate
depends on the function that describes the relationship between
distance and wind speed. Is it "flat" enough to allow linear
interpolation between two values? Or are you better served by trying to
fit all the data points you have to a polynomial or other suitable
mathematical expression first, which you then use to calculate the new
points?

A bit of literature research is indicated before you can start to cut
some code here, in my opinion...

--
Peter Below (TeamB)


Hi Peter,
Yes, you are correct in thinking this is just a pure interpolation/estimation. I do understand the risks involved with this particular application of interpolation.
I think the best outcome is to fit all known information into a polynomial expression to get a better outcome, but that is way above my capabilities.

So if a storm's max wind is only 40 knots, then I will at least have the extent of the 34 knot wind field given to me. With that, I would like to get x distance for a given wind speed.
Say... 25 knot wind field extent. (which would be larger than the 34 knot wind field)
If a storm has a max wind speed of 150 knots, then I will be given the extent of the 34, 50 and 64 knot wind fields. So with those 3 data point, I would like to get the distance
of a wind field of the 25, 83, 96, 113 knot wind fields.

I just don't have a clue on how do to it. Math was always a weak point for me.
Kind Regards,
Bryan
Adem Meda

Posts: 495
Registered: 12/28/98
Re: Help with Interpolation of data based on given input  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 25, 2014 5:32 PM   in response to: Bryan Ray in response to: Bryan Ray
Bryan Ray wrote:

I think the best outcome is to fit all known information into a
polynomial expression to get a better outcome, but that is way above
my capabilities.

No, it isn't. :)

You can start here (short read) :



If you look at the image in the link, you will see a TMemo that contains a
tabulation and then results of interpolation ('coeficients') below the
tabulation.

In the case of the example there, using those 'coeeficients', the function
would be:

y = -1.0830*x^2 + 10.5900*x - 7.8267

You can, now, use this function to calculate the value of 'y' for any given 'x'.

Note that, in that picture, 'Number of terms' was given as 3. That is why the
above function ('y') has 3 terms.

You can try different values for 'Number of terms' and see which one gives you
the best 'correlation coefficinet' (the higher the better).

But, remember, you have to construct the function (i.e. 'y = ...') correctly
for the number of terms you have selected.

So, if 'Number of terms' is 4, then y = A*x^3 + B*x^2 + C*x + D

For 5 --> y = A*x^4 + B*x^3 + C*x^2 + D*x + E

etc.

PS: In case you miss it, this is the file you need to download. It is written
in Delphi. https://bitbucket.org/wpostma/curvefit/downloads/curvefit.zip
Bryan Ray

Posts: 31
Registered: 3/2/07
Re: Help with Interpolation of data based on given input  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 25, 2014 7:37 PM   in response to: Adem Meda in response to: Adem Meda
Adem Meda wrote:
Bryan Ray wrote:

I think the best outcome is to fit all known information into a
polynomial expression to get a better outcome, but that is way above
my capabilities.

No, it isn't. :)

You can start here (short read) :



If you look at the image in the link, you will see a TMemo that contains a
tabulation and then results of interpolation ('coeficients') below the
tabulation.

In the case of the example there, using those 'coeeficients', the function
would be:

y = -1.0830*x^2 + 10.5900*x - 7.8267

You can, now, use this function to calculate the value of 'y' for any given 'x'.

Note that, in that picture, 'Number of terms' was given as 3. That is why the
above function ('y') has 3 terms.

You can try different values for 'Number of terms' and see which one gives you
the best 'correlation coefficinet' (the higher the better).

But, remember, you have to construct the function (i.e. 'y = ...') correctly
for the number of terms you have selected.

So, if 'Number of terms' is 4, then y = A*x^3 + B*x^2 + C*x + D

For 5 --> y = A*x^4 + B*x^3 + C*x^2 + D*x + E

etc.

PS: In case you miss it, this is the file you need to download. It is written
in Delphi. https://bitbucket.org/wpostma/curvefit/downloads/curvefit.zip

Adem,
Thank you for your explanation and sample test program. I am still very confused on how I can use this, but I will study it.
Hopefully, I will begin to understand the CurveFit program and how I can apply it to my current problem.

Kind Regards,
Bryan
Adem Meda

Posts: 495
Registered: 12/28/98
Re: Help with Interpolation of data based on given input  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 25, 2014 8:07 PM   in response to: Bryan Ray in response to: Bryan Ray
Bryan Ray wrote:

Thank you for your explanation and sample test program. I am still very
confused on how I can use this, but I will study it. Hopefully, I will begin
to understand the CurveFit program and how I can apply it to my current
problem.

If I you're not math-type, please do not /study/ any of the stuff in
CurveFit.pas as it will only serve to put you off.

This is the only thing that matters:

procedure PolyFit(
  const x, y: array of Double;
  var coefs: array of Double;
  var correl_coef: Double;
  const npoints, nterms: Integer
);


Post here a list of the values, and I'll jot down a snippet for it.
David Taylor

Posts: 27
Registered: 9/12/08
Re: Help with Interpolation of data based on given input  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 25, 2014 11:56 PM   in response to: Bryan Ray in response to: Bryan Ray
Adem,
Thank you for your explanation and sample test program. I am still very confused on how I can use this, but I will study it.
Hopefully, I will begin to understand the CurveFit program and how I can apply it to my current problem.

Kind Regards,
Bryan
==================================

Bryan,

What I have done in the past when using CurveFit is to try and
re-specify the problem into a different "space" so that the problem
becomes a straight-line fit. I wish I could help more directly, but I'm
"blind" to your problem at the moment.

Good to know that the code I wrote and adapted is doing a good job for
others!

Cheers,
David
--
David
Web: http://www.satsignal.eu
Alex Belo

Posts: 626
Registered: 10/8/06
Re: Help with Interpolation of data based on given input  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 25, 2014 8:06 PM   in response to: Bryan Ray in response to: Bryan Ray
Bryan, you can try plaing with you data in Excel, it has some functions
for interpolation. Select acceptable method and find its implementation
in internet or let us know about your choice so we can assist.

--
Alex
Bryan Ray

Posts: 31
Registered: 3/2/07
Re: Help with Interpolation of data based on given input  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 26, 2014 10:35 AM   in response to: Bryan Ray in response to: Bryan Ray
Thank you all for trying to help me with my problem.
I've created a simple excel spreadsheet to give a better understanding of what I need and attached it to the Attachments forum (Wind distance interpolation)
I hope it helps to make my problem clear.

Many thanks for your help and suggestions.
Regards,
Bryan
Alex Belo

Posts: 626
Registered: 10/8/06
Re: Help with Interpolation of data based on given input  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 27, 2014 12:08 AM   in response to: Bryan Ray in response to: Bryan Ray
Bryan Ray wrote:

I've created a simple excel spreadsheet to give a better
understanding of what I need

OK, your problem is more clear now.

Your problem not interpolation only (as in the second example where you
wish to interpolate value at point 83 between points 64 and 96) but
extrapolation too.

Interpolation (especially without high requirements to presision) is
less sensible to absence of theoretical trend; in most cases we can
simply assume that data is "smooth" enough.

But blind extrapolation will most likely give nonsensical result
without theoretical model.

What is theoretical model of the function Distanse(WindSpeed)? If you
have some formula with some unknown coefficient(s) you can find them
using technique of least squares. After that you can use obtained
function for interpolation/extrapolation. But note: if you have too
little points the result will be not very accurate due to noise in
experimental data.

Now about your data. Looking at known points we can surmise that this
can be quadratic parabola in boundaries of interest (34<ws<100). But
there is no enough points to be sure. Why you have only 3-4 known
points? Is this possible to get more data?

If quadratic parabola is adequate model (for some known to you reason)
you can use curvefit.zip as Adem advise.

--
Alex
Adem Meda

Posts: 495
Registered: 12/28/98
Re: Help with Interpolation of data based on given input  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 27, 2014 5:02 AM   in response to: Bryan Ray in response to: Bryan Ray
Bryan Ray wrote:

I've created a simple excel spreadsheet to give a better understanding of
what I need and attached it to the Attachments forum (Wind distance
interpolation) I hope it helps to make my problem clear.

I have placed a compiled exe (in a 7z file) and an image in the Attachments.

For a littel better usability, I have made some modifications to
TestCurveFit.exe.

When you run it, you will see a Memo on top left.

You need to input your X and Y points there. When you get there, a hint comes
up and explains how they must be separated (space is fine).

When you fill in your coordinate points, press the 'Process' button.

The important thing you'll get is just above that button: A formula that
represents your values.

For values below:

34 80
50 40
64 25

It will return a correlation of 1.

And, the formula will be 'y := (0.0476190476190553 * x^2) - (6.50000000000075 *
x) + 245.952380952398'.

This is for 3 terms. You can try different number of terms.

With the above formula (3 terms), I produced a chart in Excel (see attachments).

While I have no idea whether it means anything in your field, but the one thing
that stands out is that for any distance below 64, this formula predicts rising
speeds.

I don't know, it may or may not be meaningful; if not, you should not use for
speeds lower than that.

I also suggest you try other number of terms and use the resulting formula to
produce a chart in Excel (because it is ideal for quick and dirty stuff like
that).

Finally, I don't think you will have any difficulty translating that formula to
Delphi. If you do, however, just post here.
Bryan Ray

Posts: 31
Registered: 3/2/07
Re: Help with Interpolation of data based on given input  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 27, 2014 4:16 PM   in response to: Adem Meda in response to: Adem Meda
Adem Meda wrote:
Bryan Ray wrote:

I've created a simple excel spreadsheet to give a better understanding of
what I need and attached it to the Attachments forum (Wind distance
interpolation) I hope it helps to make my problem clear.

I have placed a compiled exe (in a 7z file) and an image in the Attachments.

For a littel better usability, I have made some modifications to
TestCurveFit.exe.

When you run it, you will see a Memo on top left.

You need to input your X and Y points there. When you get there, a hint comes
up and explains how they must be separated (space is fine).

When you fill in your coordinate points, press the 'Process' button.

The important thing you'll get is just above that button: A formula that
represents your values.

For values below:

34 80
50 40
64 25

It will return a correlation of 1.

And, the formula will be 'y := (0.0476190476190553 * x^2) - (6.50000000000075 *
x) + 245.952380952398'.

This is for 3 terms. You can try different number of terms.

With the above formula (3 terms), I produced a chart in Excel (see attachments).

While I have no idea whether it means anything in your field, but the one thing
that stands out is that for any distance below 64, this formula predicts rising
speeds.

I don't know, it may or may not be meaningful; if not, you should not use for
speeds lower than that.

I also suggest you try other number of terms and use the resulting formula to
produce a chart in Excel (because it is ideal for quick and dirty stuff like
that).

Finally, I don't think you will have any difficulty translating that formula to
Delphi. If you do, however, just post here.

Adem,
If I understand you correctly (and the PolyFit) program, I can input the 3 control points (X,Y) and it will provide a formula such as this format:
y := (0.0684523809523985 * x^2) - (11.3750000000017 * x) + 507.619047619087

So my unknown distance is Y, and I provide the X for the known variable of wind speed.

My next question, how do I generate this formula? y := (0.0684523809523985 * x^2) - (11.3750000000017 * x) + 507.619047619087
Because this formula will vary based on the input (X,Y) control points.

Sorry for so many questions. This is new and complex for me, but I am very willing to learn as much as I can.

Is that correct?
Kind Regards,
Bryan
Adem Meda

Posts: 495
Registered: 12/28/98
Re: Help with Interpolation of data based on given input  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 27, 2014 5:52 PM   in response to: Bryan Ray in response to: Bryan Ray
Bryan Ray wrote:

So my unknown distance is Y, and I provide the X for the known variable of
wind speed.

Yes.

My next question, how do I generate this formula? y := (0.0684523809523985 *
x^2) - (11.3750000000017 * x) + 507.619047619087 Because this formula will
vary based on the input (X,Y) control points.

That's easy.

procedure PolyFit(
const x, y: array of Double;
var coefs: array of Double;
var correl_coef: Double;
const npoints: Integer
nterms: Integer);

To this procedure, you supply 2 arrays (and y) and how many elements those 2
array have (npoints) and also how many terms you want your formula to be.

When it finishes, you get back an array (coefs) which holds the multipliers for
your formula.

IOW, in this formula I gave you,

y := (0.0684523809523985 * x^2) - (11.3750000000017 * x) + 507.619047619087

PolyFit() had returned

coefs[2] as 0.0684523809523985
coefs[1] as 11.3750000000017
coefs[0] as 507.619047619087

All I have done is to turn it into a human-readable formula.

But, if I am not mistaken, you seem to want to generate a formula for every 3
pairs of inputs. If so, this is not a good idea.

What you should do is this: Put ALL data into one single array and call
PolyFit() with them. The more the better. That way you will get a formula that
will be a lot more healthy.

IOW, what I trying to say is this: 3 pairs don't make a reliable set for
statistics. Hundreds, thousands (or even millions) of pairs are MUCH better.

Sorry for so many questions. This is new and complex for me, but I am very
willing to learn as much as I can.

That's a good thing.

As long as you don't expect me (or anyone else, for that matter) to write the
app, I am willing to help.
Bryan Ray

Posts: 31
Registered: 3/2/07
Re: Help with Interpolation of data based on given input  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 1, 2014 3:29 PM   in response to: Adem Meda in response to: Adem Meda
Adem Meda wrote:
Bryan Ray wrote:

So my unknown distance is Y, and I provide the X for the known variable of
wind speed.

Yes.

My next question, how do I generate this formula? y := (0.0684523809523985 *
x^2) - (11.3750000000017 * x) + 507.619047619087 Because this formula will
vary based on the input (X,Y) control points.

That's easy.

procedure PolyFit(
const x, y: array of Double;
var coefs: array of Double;
var correl_coef: Double;
const npoints: Integer
nterms: Integer);

To this procedure, you supply 2 arrays (and y) and how many elements those 2
array have (npoints) and also how many terms you want your formula to be.

When it finishes, you get back an array (coefs) which holds the multipliers for
your formula.

IOW, in this formula I gave you,

y := (0.0684523809523985 * x^2) - (11.3750000000017 * x) + 507.619047619087

PolyFit() had returned

coefs[2] as 0.0684523809523985
coefs[1] as 11.3750000000017
coefs[0] as 507.619047619087

All I have done is to turn it into a human-readable formula.

But, if I am not mistaken, you seem to want to generate a formula for every 3
pairs of inputs. If so, this is not a good idea.

What you should do is this: Put ALL data into one single array and call
PolyFit() with them. The more the better. That way you will get a formula that
will be a lot more healthy.

IOW, what I trying to say is this: 3 pairs don't make a reliable set for
statistics. Hundreds, thousands (or even millions) of pairs are MUCH better.

Sorry for so many questions. This is new and complex for me, but I am very
willing to learn as much as I can.

That's a good thing.

As long as you don't expect me (or anyone else, for that matter) to write the
app, I am willing to help.

Adem,
I think I'm almost there, but I am not getting the values I expected. Maybe it is something simple I am doing wrong.
I've attached a small sample app in the attachments forum (WindRadius).
I've set the variable I need as the distance to the edge of 80 knots. The expected value should be less than the given value at 64 knots, but it is much larger.

Any chance you have time to take a quick look and give me a hint?
Kind Regards,
Bryan
Adem Meda

Posts: 495
Registered: 12/28/98
Re: Help with Interpolation of data based on given input
Correct
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 2, 2014 1:29 AM   in response to: Bryan Ray in response to: Bryan Ray
Bryan Ray wrote:

Adem Meda wrote:
Bryan Ray wrote:

So my unknown distance is Y, and I provide the X for the known variable of
wind speed.

Yes.

My next question, how do I generate this formula? y :=
(0.0684523809523985 * x^2) - (11.3750000000017 * x) + 507.619047619087
Because this formula will vary based on the input (X,Y) control points.

That's easy.

procedure PolyFit(
const x, y: array of Double;
var coefs: array of Double;
var correl_coef: Double;
const npoints: Integer
nterms: Integer);

To this procedure, you supply 2 arrays (and y) and how many elements those 2
array have (npoints) and also how many terms you want your formula to be.

When it finishes, you get back an array (coefs) which holds the multipliers
for your formula.

IOW, in this formula I gave you,

y := (0.0684523809523985 * x^2) - (11.3750000000017 * x) + 507.619047619087

PolyFit() had returned

coefs[2] as 0.0684523809523985
coefs[1] as 11.3750000000017
coefs[0] as 507.619047619087

All I have done is to turn it into a human-readable formula.

But, if I am not mistaken, you seem to want to generate a formula for every
3 pairs of inputs. If so, this is not a good idea.

What you should do is this: Put ALL data into one single array and call
PolyFit() with them. The more the better. That way you will get a formula
that will be a lot more healthy.

IOW, what I trying to say is this: 3 pairs don't make a reliable set for
statistics. Hundreds, thousands (or even millions) of pairs are MUCH better.

Sorry for so many questions. This is new and complex for me, but I am
very willing to learn as much as I can.

That's a good thing.

As long as you don't expect me (or anyone else, for that matter) to write
the app, I am willing to help.

Adem,
I think I'm almost there, but I am not getting the values I expected. Maybe
it is something simple I am doing wrong. I've attached a small sample app in
the attachments forum (WindRadius). I've set the variable I need as the
distance to the edge of 80 knots. The expected value should be less than the
given value at 64 knots, but it is much larger.

Any chance you have time to take a quick look and give me a hint?

Bryan,

Your .dpr uses FMX stuff. I don't have it installed in my system. As a result I
couldn't compile it here.

But, going through the code, I noticed a couple of things:

1) numPoints is what you set your arrays to. See, the (corrected) SetLength()
lines for x and y.

2) nterms is the length of your 'c' array. It should have been SetLength(c,
nterms).

3) Regarding 'Formula' and 'ResultVal': You used negative signs in them
arbitrarily. You should not do that.

'Sign' information comes from the values of your 'c' array. See the corected
'Formula' and 'ResultVal'.

As I said, I didn't compile and run this; however, I see no reason it shouldn't
give you correct/proper results this time.

procedure TForm1.Button1Click(Sender: TObject);
var
  x, y, c : array of double;
  Correlation, resultVal : double;
  numPoints, nterms, neededDistance : Integer;
begin
  NeededDistance := StrToInt(editInputWind.text);
  NumPoints := 3;
  nterms := 3;
  SetLength(x, NumPoints);
  SetLength(y, NumPoints);
  SetLength(c, nterms);
 
 
  y[0] := StrToFloat(edit34.Text);  //This is a given value
  y[1] := StrToFloat(edit50.Text);  //This is a given value
  y[2] := StrToFloat(edit64.Text);  //This is a given value
 
  x[0] := 34;
  x[1] := 50;
  x[2] := 64;
 
  PolyFit(x, y, c, Correlation, numPoints, nterms);
 
  Label5.Text := 'Formula:  y= (' + FloatToStr(c[2]) + ' * x^2) + (' +
FloatToStr(c[1]) + ' * x) + ' + FloatToStr(c[0]);
 
  Label9.Text := 'Correlation = ' + FloatToStr(Correlation);
  ResultVal := (c[2] * power(NeededDistance,2)) + (c[1] * NeededDistance) +
c[0];
  Label7.Text := 'Needed Distance is: ' + FloatToStr(ResultVal);
end;
Bryan Ray

Posts: 31
Registered: 3/2/07
Re: Help with Interpolation of data based on given input  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 2, 2014 4:37 PM   in response to: Adem Meda in response to: Adem Meda
Adem,
Thank you so much for your help. It looks like I'm getting some reasonable results.

Regards,
Bryan
Adem Meda

Posts: 495
Registered: 12/28/98
Re: Help with Interpolation of data based on given input  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 2, 2014 5:09 PM   in response to: Bryan Ray in response to: Bryan Ray
Bryan Ray wrote:

Bryan,

It looks like I'm getting some reasonable results.

I am just curious: In what way have I indirectly and in the smallest bit
contributed to the advancement and prosperity of human race :)

IOW, can you jot down a few lines where the results are going to be used.
Bryan Ray

Posts: 31
Registered: 3/2/07
Re: Help with Interpolation of data based on given input  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 2, 2014 7:06 PM   in response to: Adem Meda in response to: Adem Meda
Adem Meda wrote:
Bryan Ray wrote:

Bryan,

It looks like I'm getting some reasonable results.

I am just curious: In what way have I indirectly and in the smallest bit
contributed to the advancement and prosperity of human race :)

IOW, can you jot down a few lines where the results are going to be used.

Adem,
I am making an iPad app that tracks and displays severe weather (tornado, large hail, high winds, earthquakes, and tropical cyclones). The tropical cyclone part of the app will give users a breakdown of the expected winds at the user's location as the cyclone approaches. So the part you helped me solve was to show the user when each category of wind will hit their location. 34 knots = Tropical Storm, 50 knots is generally associated with severe weather, 64 knots is category 1 hurricane winds, 83 knots is Cat 2 winds, 96 knots is Cat 3 winds, 114 knots is Cat 4 winds and > 135 knots is Cat 5. With your help I can now interpolate/extrapolate all of these categories and relate them to a distance from the center of the storm outward.

Cheers,
Bryan
Shlomo Abuisak

Posts: 100
Registered: 9/18/10
Re: Help with Interpolation of data based on given input  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 20, 2015 12:07 AM   in response to: Bryan Ray in response to: Bryan Ray
On 25/05/2014 19:46, Bryan Ray wrote:
To image what I need, think about a hurricane. The winds are stronger towards the center of the storm and weaker as you go further from the center.

I am given the distance (in miles) from the center to reach the edge of the 34 knot, 50 knot and 64 knot winds. So the 34 knot winds will extend much further outward than the 64 knot winds.
Sometimes the max winds of the storm are less than 64 knots so the 64 knot extent will be 0.

Here's my attempt at the algorithm. Unfortunately I'm stuck.
The results I would like to get is give an input needed wind speed value, and the result would be the distance from the center in miles to get to that distance.
Any help would be greatly appreciated.
Regards,
Bryan

                                              //100kts          75 mi         100mi           250mi       //83kts Val
function TStorm.GetIntervalWindRadiusDistance(StormMaxWindSpeed, GivenDistTo64, GivenDistTo50, GivenDistTo34, NeededDistanceOfThisWind : Integer): Integer;
    {Expected result is a smaller result value for a higher NeededWindDistance (Highest winds closest to center) }
Const Delta3450 = 16; Delta5064 = 14;  Delta3464 = 30;
var
   KnotsIncreasePerMile : Double;
begin
    {Example: if needed Distance to 135 knots and the max winds are only 100 knots, then return 0}
   If NeededDistanceofThisWind > MaxWindSpeed then
     Result := 0
   else
   begin
     if NeededDistanceOfThisWind > 64 then
     begin
       KnotsIncreasePerMile := Delta5064 / (Abs(GivenDistTo64 - GivenDistTo50));
                                // 14             75               100        =25  = .56 miles per knot increase??
       Result := KnotsIncreasePerMile * NeededDistanceOfThisWind;
     end;
   //  if (NeededDistanceOfThisWind < 64) and (NeededDistanceOfThisWind > 50) then
 
   //  if NeededDistanceOfThisWind < 34 then
 
   end;
 
end;
 

I have an interpolation program in java and pascal
http://limelect.com/Android/wind/ although in Hebrew it is
a wind program for android in java
the line in the center is the interpolation
i have the same in pascal for desktop program (very old)
get in touch personally.
It nite help? limelect at gmail dot com
luke lonergan

Posts: 12
Registered: 8/25/16
Re: Help with Interpolation of data based on given input  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 8, 2016 2:42 AM   in response to: Bryan Ray in response to: Bryan Ray
Serving as the CEO of Big Data Developer, LLC, Luke Lonergan has demonstrated a profound commitment to fulfilling his responsibilities.

Edited by: luke lonergan on Aug 8, 2016 2:50 AM
ann mariya

Posts: 1
Registered: 12/9/16
Re: Help with Interpolation of data based on given input  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 9, 2016 12:56 AM   in response to: Bryan Ray in response to: Bryan Ray
Information provided here about the interpolation of data based on given input is really a useful one. Hope this topic have great relevance in the recent days and i enjoyed it a lot. Thanks for sharing. I am working as a writer in research paper writing service reviews, you can contact us for any writing help.

Edited by: ann mariya on Nov 9, 2016 12:57 AM
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02