Consensus of three numbers in the range -1 and 1 - statistics

I am going to use an innovative method to aggregate three numbers whose values are between -1 and 1. I also want to ignore zeros. Therefore, if the two values are equal to 0 and 0.5, respectively, the expected output is about 0.4.
Also, for two inputs with values of 0.2 and 0.1, the expected output is a number between them (which is closer to the larger number), something like 0.7.
If the inputs are -0.2 and 0, the expected output is about -0.19.
To simplify, I have given my examples with two numbers.
I apologize for my poor writing.
thanks for your help.

Related

Excel internal expression of fractional format numbers

I have been trying to apply some conditional formatting to numbers which are formatted externally as fractions with a mask ???/???. In trying to test whether the fraction has a numerator of 1, I apply the formula = =MOD(1/G62,0)<>0, which divides 1 by the fraction itself, which ought to divide with no remainder if it has a numerator of 1, and return 0. If it returns something else then it has a numerator other than 1.
The rule is satisfied when it should not be. To test what is going on, I deconstruct the formula.
The fraction 1/28 is divided into 1 to give 28 and this is correctly displayed. I then populate another cell using the formula =MOD(H62,1) to 28 and it gives 0, as it should. I do the same thing for 1/14 and the result is 1. In other words the MOD of 14, 1 is 1! When I look at the decimal representation of the 2 fractions( I imagine the fractions are actually the representations of the decimal numbers, which themselves will be binary or hex numbers internally), I see the following.
1/28 0.0357142857142856
1/14 0.0714285714285716
When the decimal for 1/28 is subtracted from the decimal for 1/14, the result is 0.035714285714286.
As 1/28 can probably never be accurately represented in decimal, it looks like some rounding down has taken place. Most probably when MOD is applied to the decimal representation of 1/28 with 1, that decimal representation of 1/14 does not divide equally into 1, and this discrepancy is disclosed by the subtraction above.
I am using excel 2016. Maybe this is no longer a problem.
What I am trying to do is test to see if the lowest numerator of a fractional number is 1. Perhaps there is another way to do this in Excel. If so, let me know.

Excel formula that if true uses value but if false repeats until true

My formula is
=NORM.INV(RAND(), 0.08, 0.06)
basically generating random values in the normal distribution with probability between 0 and 1, mean 0.08 and standard deviation 0.06. What I need to happen is ensure that my output is greater than or equal to 0.03. Basically, if the output of the formula is greater than or equal to 0.03, fantastic, put that output in the cell. If the output of the formula is less than 0.03, repeat until greater and then use that value etc etc. Cannot seem to work it out
You cannot make the formula work until the desired result is achieved, but you can limit the parameters so that the non-desired result will not achieved. In this case, the RAND should be limited to values greater than 0.2025. You can use RANDBETWEEN:
=NORM.INV(RANDBETWEEN(2025;10^4)/10^4; 0.08; 0.06)

Excel: How to find closest number in table, many times

Excel
Need to find nearest float in a table, for each integer 0..99
https://www.excel-easy.com/examples/closest-match.html explains a great technique for finding the CLOSEST number from an array to a constant cell.
I need to perform this for many values (specifically, find nearest to a vertical list of integers 0..99 from within a list of floats).
Array formulas don't allow the compare-to value (integers) to change as we move down the list of integers, it treats it like a constant location.
I tried Tables, referring to the integers (works) but the formula from the above web site requires an Array operation (F2, control shift Enter), which are not permitted in Tables. Correction: You can enter the formula, control-enter the array function for one cell, copy the formulas, then insert table. Don't change the search cell reference!
Update:
I can still use array operations, but I manually have to copy the desired function into each 100 target cells. No biggie.
Fixed typo in formula. See end of question for details about "perfection".
Example code:
AI4=some integer
AJ4=MATCH(MIN(ABS(Table[float_column]-AI4)), ABS(Table[float_column]-AI4), 0)
repeat for subsequent integers in AI5...AI103
Example data:
0.1 <= matches 0
0.5
0.95 <= matches 1
1.51 <= matches 2
2.89
Consider the case where target=5, and 4.5, 5.5 exist in the list. One gives -0.5 and the other +0.5. Searching for ABS(-.5) will give the first one. Either one is decent, unless your data is non-monotonic.
This still needs a better solution.
Thanks in advance!
I had another problem, which pushed to a better solution.
Specifically, since the Y values for the X that I am interested in can be at varying distances in X, I will interpolate X between the X point before and after. Ie search for less than or equal, also greater than or equal, interpolate the desired X, then interpolate the Y values.
I could go a step further and interpolate N - 1 to N + 1, which will give cleaner results for noisy data.

How certain arrays and array functions are handled under the hood in Excel; specifically the dependence of array handling on the calling function

In trying to systematically enumerate the possibilities when rolling four identical but loaded four-sided dice, I came across some unusual excel behavior. Hoping someone can shed some light on what's going on under the hood.
The following table illustrates the possible rolls of a die:
1000 A
0100 B
0010 C
0001 D
each row is a possibility with a distinct probability. In excel, this information can be made to occupy a 4x4 cell area--that is, the letter labels above are merely for convenience.
In trying to display all possible combinations of four rolls of such a die-- where the fist combination might be A + A + A + A or 4000, the second might be B + A + A + A or 3100, and so on for each of the 4^4=256 possibilities--I decided that I wanted to systematically offset A by 0,1,2, or 3 rows for each of four rolls then sum the results. In other words, each possible group of 4 roles can be thought of as 4 copies of row A, each of which offset by some number of rows between 0 and 3, for example {0;0;0;0} or {1;0;0;0} in the first and second case enumerated directly above.
Oddly, though, I get the following. (all formulas are array formulas keyed in with shift+ctrl+enter).
=TRANSPOSE( SUM( OFFSET( A, 4x1ArrayOfRowOffsets, 0)))
displays the correct sum when entered into a 1x4 range. Likewise if =TRANSPOSE(...) is replaced by =INDEX(...,1,1). I take it because both functions natively support array arguments. However,
=SUM( OFFSET( A, 4x1ArrayOfRowOffsets, 0))
does not work--it seems that here the summation is conducted along the 4 rows returned by offset, each of which has value 1--it incorrectly displays only the value 1, even when evaluated in a multicell range as an array formula. Oddly,
=SUM( TRANSPOSE( OFFSET( A, 4x1ArrayOfRowOffsets, 0)))
does not work either--the transpose makes it so the summation is properly conducted along the columns returned by offset, but seems to throw out all but the first column.
Please note that, although the problem statement does not involve VBA, the lack of transparent array formula auditing in Excel proper (intermediate steps return #VALUE errors even when the final answer computes) likely means that, in order to investigate this problem, someone will have to write a bit of VBA that calls worksheet functions and manually outputs the intermediate calculations. This is why I posed a version of this question, here.
Interweaving INDEX calls anywhere but the outside/first function call does not fix the problem.
To try and see what is going on, I investigated further.
=INDEX( OFFSET( A, {w;x;y;z}, 0), 1, {1,2,3,4})
correctly displays the four rolls when entered into a 4x4 range. As before w, x, y, and z are integers between 0 and 3 indicating row offsets from "A" in the table, above. Furthermore,
=COLUMNS( OFFSET( A, {w;x;y;z}, 0))
returns the following when entered into a 5x5 range:
4 4 4 4 4
4 4 4 4 4
4 4 4 4 4
4 4 4 4 4
n/a n/a n/a n/a
All that is to say, calling SUM(OFFSET(---)) with array arguments seems to produce varied output depending on what is doing the calling--specifically, whether or not the caller is a function which natively accepts proper array arguments. Why is this? What is actually going on, here?

Excel gives a False instead of True for simple formula

I just stumbled on an Excel 2013 problem I've never encountered.
Briefly, I have a column (= V for my particular sheet) that returns a 0 or 1 based on two numbers matching exactly (i.e., no rounding errors). This is simple error checking for my work.
In cell F31, I have = 0.1 (manually entered). In cells M31, L31, and J31, I have 4.5, 0.0, and 4.4, respectively. A formula in cell Q31 is
Q31 = M31 - L31 - J31. This is 4.5 - 0.0 - 4.4 = 0.1. None of these numbers come from other formulae. There should be no rounding errors.
Now, in column V31, I have If(Q31=F31,0,1). No doubt that 0.1 [F31] = 0.1 [Q31], but the return value in V is 1. This makes no sense!
If I enter other values so that Q31 does not = 0.1 but F31 = Q31, the return value is 0 (or Q31 = F31) as it should be. For example, I can change F31 to 0.2 and L31 to 4.3 so that 0.2 = 0.2 based on 4.5 - 0.0 - 4.3. This works fine.
What's up with the 0.1?
Many thanks!
Eric
Floating point numbers are "almost never" equal. It's due to floating point arithmetic and precision.
Not all decimal numbers have an exact floating-point representation. A value you enter by hand, must be replaced by Excel by the closest floating-point representation. Also, a value resulting from calculation is replaced by the floating-point unit of the processor by its closest value.
When comparing floating point numbers, use some "epsilon" tolerance. Use something like this for your V31 formula:
=IF(ABS(Q31-F31) < 1e-10, 0, 1)
This compares the two numbers up to the 10th decimal digit.
For flexibility, you can define a "Name" for your tolerance constant, "TOL" in the name manager, so that you can change it in one place without editing your formulas.
=IF(ABS(Q31-F31) < TOL, 0, 1)
The choice of the tolerance depends on your application.1e-10 is a good choice in many cases.

Resources