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 working out what the changes of a horse winning a race is from the previous records of each horses.
Horse 1 has won 5% of his races
Horse 2 has won 7% of his races
Horse 3 has won 12% of his races
Now if 3 horses are running in this final race, how do I split 100% between these 3 horses?
By doing this I guess :
5 + 7 + 12 = 24
Horse 1 :
5 * 100 / 24 = 20.83
Horse 2 :
7 * 100 / 24 = 29.17
Horse 3 :
12 * 100 / 24 = 50
(20.83 + 29.17 + 50 = 100)
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 5 years ago.
Improve this question
What type of series it is and how to generate this by php program?
0 1 3 2 6 7 5 4 12 13 15 14 ...
Observation: The successive difference of the entity is 1
Example:
Difference of 0 and 1 is 1
Difference of 3 and 2 is 1
Difference of 6 and 7 is 1
Difference of 5 and 4 is 1
Difference of 12 and 13 is 1
Difference of 15 and 14 is 1
Please help ...
Its a Decimal Equivalent of Gray code up to n. I have written a code to generate the Gray code for any Number, Use this to generate a series. I have used Javascript, but you can choose any language you want.
Number.toGrayCode = function(n) {
if (n < 0) {
throw new RangeError("cannot convert negative numbers to gray code");
}
return n ^ (n >>> 1);
};
for( var i=0;i<=10;i++)
console.log(Number.toGrayCode(i));
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 creating a fee calculator and fee is calculated on based of capital. So I want a formula in php.
if capital is <=1000000 then fee is 1000
if capital is 1100000 - 2000000 fee is 2000
if capital is 2100000 - 3000000 fee is 3000
if capital is 3100000 - 4000000 fee is 4000
if capital is 4100000 - 5000000 fee is 5000
and so on
so what i want is i want a formula that will give me a fee of 1000 per 10 Lakh
Assuming your variable is called $capital, then this should work:
print ((int)(1000*ceil($capital/1000000)));
It divides by 1000000, rounds up, then multiplies by 1000.
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 have a table named 'prices' and every range has its price.
course_id start end price
-----------------------------
1 1 5 20
1 5 10 18
1 10 100 15
-------------------------
I have for example $course_id = 1 and $weeks_num = 8.
How can I get the price of that course?
In the given example I should have 18 because 8 exists between 5 and 10.
You can use BETWEEN clause. http://dev.mysql.com/doc/refman/5.7/en/comparison-operators.html#operator_between
...
WHERE 8 BETWEEN start AND end
...
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 grades from 1 to 5 where 1 is the best and 5 is the worst(But not just integral numbers like 1, also 1.14 and so on).
I want to calculate how many stars each grade would be(5 stars would be the best, 1 star the worst - 3 would stay 3 of course - but the rest?)
I googled to get the result but I'm not finding anything helpful. Maybe I'm missing the forest for the trees, I don't know. Basically it would be the reverse number I guess?
I want to do that in PHP.
Pretty straightforward I would think:
$new_grade = 6 - $old_grade;
Or for a more generic solution:
$new_grade = $grade_max + $grade_min - $old_grade;
Star = 6 - Grade
So:
5 → 1
4 → 2
3 → 3
2 → 4
1 → 5
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'm trying to work out a simple calculation for the following:
a phone model has the maximum sale price of £85.00 and this is if only 1 unit is purchased and a minimum sales price of £50.00 - this is if 150 units and over are purchased in one.
How can I work out a way of the price if between 2 and 149 units are purchased??
Thanks,
B.
Formula:
Y = 50 + ((85 - 50) / (150 - 1)) * (X - 1)
Result:
X = 1 --> Y = 85
X = 33 --> Y = 57.52
X = 150 --> Y = 50
You probably don't have a linear model in such situations. I don't know the right English term, but you would have more like a piecewise or stepwise function here.
But nevertheless, you can get a linear function through interpolation.