Replies: 6 comments 6 replies
-
You mention that the type of the curve is always the same, do you know if the curve has any analytic form? |
Beta Was this translation helpful? Give feedback.
-
It does not have an analytic form. Data like this is quite common in my line of work but the internals are all a black box. |
Beta Was this translation helpful? Give feedback.
-
Do you know if your function behaves always like eg. a parabola? Can it have multiple local extrema or does it have only a global maximum? |
Beta Was this translation helpful? Give feedback.
-
Yes it always behaves as per my example with only one hump. In other words it always rises, hits a single max, and then decreases. No data is provided below a certain y-value. In my example there is no data below y=37000. |
Beta Was this translation helpful? Give feedback.
-
I would go as far and suggest that you could use a sorting algorithm for your problem. var points = new List<(double x, double y)>
{
(0.7, 3799.99999999999),
(0.724444444444444, 4120.10582010581),
(0.748888888888889, 4360.18518518518),
(0.773333333333333, 4520.23809523809),
(0.797777777777778, 4600.26455026454),
(0.822222222222222, 4600.26455026455),
(0.846666666666667, 4520.23809523808),
(0.871111111111111, 4360.18518518516),
(0.895555555555556, 4120.10582010581),
(0.92, 3800)
};
var sortedPoints = points
.Select((p, index) => (p.x, p.y, index))
.OrderBy(v => v.y)
.ToList();
var indexOfMaximum = sortedPoints.Last().index;
var minimumValue = sortedPoints.First().y;
var maximumValue = sortedPoints.Last().y;
var intersectionLimit = 4500.0;
if (intersectionLimit < minimumValue || intersectionLimit > maximumValue)
{
// early exit, no intersection
}
var firstIndexAfterCrossing = sortedPoints.First(v => v.y >= intersectionLimit && v.index < indexOfMaximum).index;
if (firstIndexAfterCrossing == 0)
{
// you hit the start of the curve
}
var firstIndexBeforeCrossing = firstIndexAfterCrossing - 1;
// then here you do linear interpolation between (firstIndexBeforeCrossing, firstIndexAfterCrossing)
// similarly, you can find the crossing in the descending part of your curve
var secondIndexAfterCrossing = sortedPoints.Last(v => v.y <= intersectionLimit && v.index > indexOfMaximum).index; |
Beta Was this translation helpful? Give feedback.
-
@sindizzy is this discussion still active or can we close it? |
Beta Was this translation helpful? Give feedback.
-
I am not sure even how to pose the question so I will post a graphic.. The black dots are data generated from the vendor software and the results will always be the same type of curve. It will rise then at a point will start to decrease. My task is to take any y-value (in this case 43000) and determine where it crosses the curve. the x-values are determined from a curve fit. In this case the x-values corresponding to the two triangles.
Looking at the options that Math.Net has I was lookin at maybe using the Polynomial Regression but unsure if this will give me the two x-values for my one y-value. Is there another more appropriate model to use?
Beta Was this translation helpful? Give feedback.
All reactions