Calculate bottom 10% and top 10% values from quartile values [closed] - c#

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.

Related

Algorithms to brute force function inputs to find maximum [closed]

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.

How to calculate a logical curve along a set of values? [closed]

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.

Measuring waist of a person using Microsoft Kinect [closed]

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.

Incrementing across a changeable distance 0-1 keeping time equal [closed]

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.

Where can I find an algorithm for generating digital camouflage pattern? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
Here is a sample of what I'm looking to reproduce.
I thought about tiling an image but that would create a detectable pattern.
I also thought about a random pattern using 4 or 5 colors but this is not a random pattern.
Thanks!
The military uses a fractal pattern called MARPAT, which I understand is highly effective compared to other known camo patterns. However, they have patented it, and I'm not aware of any way to find out the specifics.
Your best bet is probably Perlin noise, though I'm not sure how effective it would be as actual camouflage if you printed it out and tried to hide with it. You should be able to generate something that looks a lot like military camouflage, which is probably what you're trying to do.
What I would do:
choose a few colors for your camo
create a blank canvas
seed a number of points using your colors (change random pixels to a random color)
fill in the gaps using the algorithm below.
You want this to be random but you also want some clustering for those stripes/blobs in your example. So, by filling in the gaps from the seed points outwards, you can use the surrounding pixels to influence the color decision. If a pixel is surrounded by green, then it should be more likely to be green than yellow. So, for every pixel moving outwards from the seed points:
Consider your surrounding (8, 24, etc) pixels and use those to determine the chances for each color. Each color gets assigned a range of numbers between 0 and 1 (For example, green might be .23 - .57). The sum of the ranges should include all numbers between 0 and 1.
Use a random number generator to choose a number between 0 and 1. Whatever color range the number falls into is what color that pixel should be.
Find an adjacent blank pixel, repeat.
Totally untested, but it works in my head? Haha.
EDIT And if you'd like the larger boxes that digital camo actually has (as opposed to single pixels) group the pixels into groups of 9, 16, 25, 36, etc.
Try using Perlin Noise
Along the lines of Mr E's answer, if you want to go the procedural route, look at various fractal algorithms.
Here's a map generator that uses erosion, I could imagine you layering several of those and maybe skewing things horizontally for your image: http://forums.tigsource.com/index.php?topic=5174.180
There's all sorts of other pattern generators - simulating termites, forest fires, crystal growth, etc.
Here are some examples: http://neekatave.com/ca/examples/ffire/index.php
You will see links in there to Star Logo, which is an educational MIT project that has a bunch more examples (warning, you may lose a lot of time clicking around there :)

Categories