Give 9 gifts to 5 users - excel

Ive created a game and in that game played 5 users which collected few points, Ive gived gifts manually but for next games how can i split or make in excel to calculate number of gifts,
this is ok using number format with 0 decimal places, 6+1+1+1 = 9
but in cases like this:
1+6+1+1+1 = 10, how can I make that only 9 gifts results?

You should be comparing their percent (B2/SUM(B2:B6)) against each prize as it relates to the total prize (e.g. 1/9). Since you are comparing decimal numbers with another decimal number and expecting an integer (no. of prizes), you will be rounding either up or down depending on whether you are favoring a wider distribution of the prizes or favoring the top score.
Either way you are going to have to decide whether the lowest score should always receive a prize or if the highest score should benefit from the points awarded.
The three possible formulas to start with would be,
=MROUND(C2, 1/9)*9 ◄ closest to even distribution
=FLOOR(C2, 1/9)*9 ◄ favours wider prize distribution
=CEILING(C2, 1/9)*9 ◄ rewards highest awarded points
Fill down as necessary.
Now you have to either take the highest or lowest score and adjust that to compensate for rounding the division of decimal numbers to an integer. MROUND doesn't play well with SUMPRODUCT but these two may give you a solution that you can live with.
=FLOOR($C2, 1/9)*9-((SUMPRODUCT(FLOOR($C$2:$C$6, 1/9)*9)-9)*($C2=MAX($C$2:$C$6)))
=CEILING($C2, 1/9)*9-((SUMPRODUCT(CEILING($C$2:$C$6, 1/9)*9)-9)*($C2=MAX($C$2:$C$6)))
Fill down as necessary.
If the MROUND solution is best suited to your prize distribution model, use a helper column that can determine the MROUND returns and then adjust the high score according to the sum of the helper column without circular references.

Related

Split total by percentage and receive the same result

This is a little bit complicated to describe, but I will try my best. I have a total, let's say 1000. Then I want to split it by percentages, position count is all the time different. So there can be 3 or 70 or 130 positions or whatever. Then split sum should correspond to target value.
Here is an example of the case:
I input names under Customer request
I enter percentage for position under Percentage
In amount calculation I use =CEILING($C$5*C10;10) and in all the rest of the cells the same to get numbers look nice. It is working fine but he problem is that now totals does not match. It should end up in 15550 but after calculating totals after split it is 15660.
Is there any ideas what kind of master artificial intelligent formula can do the trick to produce nice looking numbers, taking in consideration to match Total (target) in the end if Total (calculated) percentage is 100%?
P.S. Any ideas are welcomed as well. The target is to have nice looking, rounded numbers that will sum in the same number as target - total.
Since you are using CEILING, your output number (e.g. 15660) is guaranteed to be greater than or equal to your input number (e.g. 15550). This is because any time a "perfect match" isn't found, it rounds up.
My first suggestion is to instead use ROUND instead of CEILING. Right off the bat this will perform better than CEILING because ROUND can round up or down but CEILING can only round up.
E.g. try this:
= ROUND($C$5*C10,-1)
Since you provide no details as to "how" the data needs to be adjusted to meet your input value, I can't really provide any automatic solution.
One manual solution is that you can make a new column which indicates whether the data was rounded up or rounded down, and you can adjust the percentages manually to get the data you're looking for.
Here's a formula to tell you if the data is rounded up or down (e.g. put formula in cell E10 and drag down):
= CHOOSE(SIGN(D10-($C$5*C10))+2,"Round Down","Perfect Match","Round Up")
You can use this information to manually tweak your percentages. For example... if your output value is too high, you can slightly decrease some of the higher percentages that "Round Up" and slightly increase some of the lower percentages (e.g. if you have 10% and 3%, maybe change them to 10.1% and 2.9% to see if that makes a difference.)

Use MS Excel to round one number to 2 significant figures, then update another cell to match the number of decimal places

I am trying to use Microsoft Excel to format a large set of data. The data is all in decimal format and the results are paired so that we have 2 values per record. The first value is a Mass in grams, and the second value is the Uncertainty of that mass also in grams.
For example:
SampleName = S1, Mass(g) = 28.695, Uncertainty(g) = 1.601133
What I need to do is have the "Uncertainty" update to 2 significant figures, then depending on the value returned, have the "Mass" update to match the number of decimal places (or whole numbers) that the "Uncertainty" now is.
e.g.
if Uncertainty became 1.6, then Mass should become 28.6
if Uncertainty became 1.61, then Mass should become 28.69
if Uncertainty became 2, then Mass should become 29
I have attempted to use the ROUND function on the "Uncertainty" cell but then I don't know how to make the "Mass" cell update accordingly.
I have tried the following 2 ROUND formulas, which both seem to work for rounding the "Uncertainty":
=ROUND(A1,2-INT(LOG(ABS(A1))))
=ROUND(A1, 2)
Any help would be much appreciated.
This formula counts the number of decimal places in a given cell:
=LEN(RIGHT(A1,LEN(A1)-FIND(".",A1)))
So you could use this in your Round formula where you specify the number of decimals:
=ROUND(A1, LEN(RIGHT(A1,LEN(A1)-FIND(".",A1))))
To round to 2 significant figures you can use something like this:
=ROUND(uncertainty,2-(1+INT(LOG10(ABS(number)))))
To round (eg) B2 based on number of decimals in (eg) D2:
=ROUND(B2,IFERROR(LEN(RIGHT(D2,LEN(D2)-FIND(".",D2))),0))

Excluding 'N/A' answers in Excel table

Say I have a table of survey results. The scores for each answer are from 1-4 inclusive (1 worst, 4 best). An 'N/A' answer is represented as 5 - misleading when analysing!
I want to use a function in the final column that calculates the respondent's overall score for the survey. Rather than replacing 5 with 0 for a 'N/A' answer, I'd like to simply exclude that number altogether, and also exclude it from the overall maximum.
For example, say my maximum overall survey score was 80. If someone puts 'N/A' for one question, then I'd like their score to be n / 76, rather than n / 80.
Any suggestions? Feel free to ask for clarification if needed.
EDIT: See below for example image. I'm trying to get Overall Score / Max Score.
So after playing around with the available functions I stumbled across 2: COUNTIF and SUMIF.
As above, I'm trying to calculate Overall Score / Max Score.
So the formula I use is:
=SUMIF(range, "<5") / (COUNTIF(range, "<5")*4)
Stepping through the function:
=SUMIF(range, "<5") calculates the overall score (any number less than 5, ignores text)
(COUNTIF(range, "<5")*4) calculates the number of cells with numbers less than 5, ignores text. I then multiply this by the maximum score for a given question (which was 4). This gives me the maximum score possible given the number of 'N/A' responses.
Finally I divide the former by the latter and get the score I'm looking for. Hope this helps!

Rounding in an amortization table

I'm currently writing a C program that among other things generates and prints out an amortization table with numbers rounded to two digits. I get the correct numbers everywhere, that is: monthly_payment = principal_paid + interest_paid except in the last row (last payment) where occasionally my results don't add up, and off by one. For example:
MonthlyPay: 88.83, PrinPaid: 87.96, IntPaid: 0.88
Of course looking at the results printed to 6 digits it's easy to see why this is happening:
MonthlyPay: 88.834637, PrincPaid: 87.955087, IntPaid: 0.879551
What's the best way to handle a situation like this?
What do financial institutions do?
There is no standard.
There are those who say, "Once you round, use the rounded value for all further totals."
There are others who disagree, saying that you should sum the unrounded values to avoid accumulated rounding error. For example, 0.0666 + 0.0666 + 0.0666 + ... 15 times should approximately equal 1.0000, but if rounding each term to 2 decimal places before summing, ends up being 0.07 * 15 = 1.05! So that's the argument for using unrounded values. Your off-by-one is only off-by-one because you have just two terms you're summing.
I think ultimately you have to consider the pros and cons of each method. Who would be interested in the rounding errors? Just the programmers? Accounting? Customers? How does it affect those people? And can you issue a statement that clears the ambiguity, like "Values displayed to 2 decimal places." in which case you don't round anything at all, but simply display the first two decimal places everywhere.
Don't round in your calculations. Round only when displaying to end users.
The displayed values might be off by a cent here or there (maybe, but I doubt it). But if you round in your calculations, you'll end up with either total underreporting interest paid and overreporting principal paid, or vice versa.
If you don't round, your calculations will be correct enough that they won't make 1 cent of a difference unless you do massive loan values.

How to generate random numbers within a normal distribution using Excel

I want to use the RAND() function in Excel to generate a random number between 0 and 1.
However, I would like 80% of the values to fall between 0 and 0.2, 90% of the values to fall between 0 and 0.3, 95% of the values to fall between 0 and 0.5, etc.
This reminds me that I took an applied statistics course once upon a time, but not of what was actually in the course...
How is the best way to go about achieving this result using an Excel formula. Alternatively, what is this kind of statistical calculation called / any other pointers that I can Google around for.
=================
Use case:
I have a single column of meter readings, which I would like to duplicate 7 times (each column for a new month). each column has 55 000 rows. While the meter readings need to vary for each month, when taken as a time series, each meter number should have 7 realistic readings.
The aim is to produce realistic data to turn into heat maps (i.e. flag outlying meter readings)
I don't think that there is a formula which would fit exactly to your requirements. I would use a very straightforward solution:
Generate 80% of data using =RANDBETWEEN(0,20)/100
Generate 10% of data using =RANDBETWEEN(20,30)/100
Generate 5% of data using =RANDBETWEEN(30,50)/100
and so on
You can easily change the precision of generated data by modifying the parameters, for example: =RANDBETWEEN(0,2000)/10000 will generate data with up to 4 digits after decimal point.
UPDATE
Use a normal distribution for the use case, for example:
=NORMINV(RAND(), 20, 5)
where 20 is a mean value and 5 is a standard deviation.

Resources