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 4 years ago.
Improve this question
I am trying to take a float value, with an arbitrary minimum and maximum possible value, and convert it to a linear scale, for representation on a bar-shaped indicator. The problem is, I can't just lerp it between the minimum and maximum, because the maximum value will always be dramatically higher than the minimum value. I have an array of arbitrary values that I want to act as intermediate points between the minimum and maximum. Now I just need to calculate a logical best-fit curve through the points. Each value is always larger than the last, and the rate of increase in value accelerates the further up you go, but there is no simple formula for calculating this rate of acceleration.
Here's an example of the values that may be used:
6.0, 13.5, 30.0, 75.0, 375.0
where 6 is the minimum, and 375 is the maximum.
If x is exactly one of these values, I would want a simple value depending on how many total values there are, I.E 0, 0.25, 0.5, 0.75, 1. The issue is calculating the in-between values.
How would I go about achieving this? I apologize if a question like this has already been asked, as it feels like a common problem, although I didn't know what to search for. If this has already been answered before, please just point me in the right direction.
Reposting my comment as an answer, as requested.
If a curve might be y(x) = k^(ax+b), take logs of both sides and you have a linear relation. As pointed out tho, this is maths not programming.
I’d pick k = 2, e or 10 for easier implementation; a & b you work out from data.
Related
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 4 years ago.
Improve this question
There is a function like CalculateProfit(decimal a, decimal b, float c, TimeSpan d) and its each input parameter has minimum, maximum and initial value settings.
Its output is smooth but not linear, it has multiple peaks and falls. I want to bruteforce its inputs and find maximum possible output. How to optimize this without trying each possible combination? Maybe some kind of binary search?
I think the algorithm should use big delta steps at start to find most peaks and then tweak values with small deltas. Also I would bruteforce one input until I find best output and then try same for next inputs, then go back to tweaking first input and so on.
Update: the function is a complex algorithm which performs analysis on markets historical data (so it's not just a formula). Therefore I'm asking for some bruteforce optimizations, not trying to "solve" it as an equation.
You need to read about partial differential equations solvers of 2 or more variables.
https://math.oregonstate.edu/home/programs/undergrad/CalculusQuestStudyGuides/vcalc/min_max/min_max.html
Then you need to study one algorithm that can solve it, Finite Volume and Spectral Method are the most commonly used in Simulation.
https://en.wikipedia.org/wiki/Numerical_partial_differential_equations
You can find easy solutions on Matlab if you are interested in just solving your problem. C# can call Matlab functions with some setup.
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 6 years ago.
Improve this question
I am trying to create an application which is able to accurately measure the body parameters of a person like height, shoulder width and waist.
Currently I have been able to determine the height and the shoulder width of a person using skeletal tracking.
Can anybody help me out regarding how to measure the waist of a person using a Kinect!
I am coding in C# in Visual Studio.
Thanks a lot in advance!
It is hard to give you the exact code, right now, but the recipe:
First you need to understand what it entails. Every person has different proportions. Someone has a wide waist, but fit (athletic), someone has a wide waist, but has also big belly (fat figure), another has a wasp waist. Such variations are many and many...
So, you have to shoot waist in time during rotation around its axis. Then the measured width values convert to a model. After that you will read circumference of the waist plan (like from a blueprint).
EDIT:
Detailed:
If a person turns around (you know it, because the waist witdh values changes...front-left-back-rigth-front and many samples between each part of rotation) gives you the measures in time for the pattern.
Split whole time of rotation to number of samples. Each sample will determine the proportional angle of the turn. (8 samples per rotation means one sample is 45° [360°/8=45°]). Now imagine the circle. Split it into 8 circle chords. Each chord have length of the value measured during the rotation.
If the sample count is good enough, now you can reckon the circumference of the polygon. If the count of samples is too low, you can interpolate (or use another solution) the "missing" samples. The more samples you have, the more accurate result you have.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have a situation on my C programming here and just wondering whether my solution is the correct way:
I have a LED display with particle count sensor and will show 6 digit of seven segment numbers as the count value. The sensor will give voltage input value. The input is from 0V to 10V. So the range of 0V-10V need to be shown in the display as 000000 to 999999 count.
My solution is:
Display number = Input voltage * 99999.9
For example:
Display number = 10.000*99999.9=999999
Display number = 5.500*99999.9=549999
Display number = 2.300*99999.9=229999
Is this the correct solution? I notice that I will get a lot of 9 on the display value.
The most usable and user friendly solution is to ignore the fact that your most significant digit is capable of displaying up to 9 and simply multiply by 10000 unless you desperately need the maxim resolution in which case simply use a scale factor of 100000 and document that your range is 0-9.99999.
My reasoning is that it is better to either loose one digit in the accuracy across the whole range or clip just the maximum value than to have an error across the entire range.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
UPDATE: I found the following C# Library, and it is perfect for what I need.
==============================================================
So I have a collection of data points, for example: 4, 5, 2, 3, 15, 3, 3, 5
I have then calculated out the upper (Q2) and lower quartiles (Q1), which are 5 and 3 respectively.
Because of the quartiles I can reference from the lowest number to the Q1 to target the low 25% and then from the hightest value to Q2 to target the top 25%. Because I now have Q1 and Q2 I can also target the inner 50% of the values.
With this information I want to be able to figure our where 90% of the data falls and I haven't been able to find anywhere online that references getting any other percentages other than 25%.
If it helps, my server side language that I am doing these computations on is C# with .NET 4.5, but I am wanting to know the math behind it more than the programmatic way to accomplish it.
Any help is greatly appreciated. Hopefully what I have written is clear enough.
Thanks.
You ask with specific reference to the mathematics, so I won't include any code.
The first thing to do is construct the knots for a quantile function (which is a plot with probability on the x axis and value on the y axis). Do this by sorting the values to yield, in your case, this table:
Probability Value
1/8 2
4/8 3
5/8 4
7/8 5
8/8 15
Then construct a monotone cubic spline interpolator which passes through these points. You use a montotone cubic spline since (1) the quantile function can never have a negative slope and (2) it must be continuous to at least first order (as the reciprocal of the first derivative of the quantile function is the probability density function).
You can then use the interpolator to lookup other values. e.g. lookup the 90% interpolator value to give the result for which you have a 90% chance of attaining.
Of course, the intermediate values between the knots are inferred from the data and is an approximation.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I'm unable to think through this one I think it's one of those moments where the answer is really simple but I'm too close to the problem to see the solution.
I have a distance that's changeable and an object that has to traverse this distance in the same time regardless of length.
The start of the distance is valued as 0 and the end of the distance is valued as 1.
Obviously the incrementation will be smaller the larger the length to keep the times equal.
What formula could I use to calculate the 0-1 incrementation but keep the time taken equal.
I know it seems overly complicated way to increment but it's part of the third party plugin I've been given.
I'm coding in C#.
Thanks.
[EDIT]
Sorry I wasn't very clear.
For incrementation the start point is always 0 and the end point is always 1.
So the object can move += 0.5 for example.
so when the length increase from say 30 to 65 it should take longer to increment from 0 to 1.
So you are looking for a way to have a number x in the range [0,1] that maps to some y in some arbitrary range [min,max], and are looking for the increment value a such that if x -> y then x + a -> y + b for some constant b? If I have understood your question correctly, then your a value should be:
a = b / (max - min) note: make sure to format this correctly for C#, especially be sure to cast and that sort of thing.
This is basically saying that a should be the fraction of the range that a spans, that if b is half the range from min to max, then a should be 0.5, and if b spans one fifth the range, a should be 0.2.