How does this RSSI vs Distance equation work? - math

I came across this equation in a research paper, and can't seem to make sense of it. Let me give an argument for why it doesn't make sense, and perhaps someone can tell me where my flaw is?
P_L(d_0) is the RSSI value for distance 0
P_L(d_i) is the RSSI value for distance 1
d_0 is distance 0
d_i is distance 1
So if you put the two RSSI values on the left side of the equation, you have:
(RSSI value 1) - (RSSI value 0) = 10n * log ((Dist 1) / (Dist 0))
Let's consider the case when distance 1 is larger than distance 0:
(Dist 1) > (Dist 0)
Greater distance means less RSSI, so (RSSI 1) < (RSSI 0). So the left side of the equation is negative. The research paper states that n is normally between 2 and 4, so the "10n" part of the right side of the equation is positive, which means the log value must be negative, right?
But that leads to a contradiction. We said Dist 1 is greater, so the number inside the log is greater than 1, therefore the log value itself is positive. So intuitively, we have found an equation with the left side negative and the right side positive. What's going on??
(The opposite leads to a contradiction too: if dist 1 is less than dist 0, we get the left side positive and the right side negative)

According to the paper, P_L is the mean path loss for a given distance. The loss increases with the distance.

Related

F-division and T-division

I thought I understood the division concept but it seems I don't. The example explains T and F division of 42/-10 and -42/10. And my task is as follows:
You F-divided some positive number by −5 and obtained a remainder of 1 What remainder will you obtain T-dividing this number by −5?
:
Normally I wouldn't hesitate with division but I failed to understand this concept.
trunc(n) will always round towards zero.
floor(n) will always round down.
If n is positive, they will behave identically. (trunc(4.7) = 4 and floor(4.7) = 4)
But if n is negative, they will round in opposite directions. (trunc(-4.7) = -4 and floor(-4.7) = -5)
Then we just expand this so that n is the result of division. For T division, we divide and then round towards zero. For F division, we divide and then round down.

Find biases and scaling factors from multiple measurements to calibrate measurement data

Let's define that we have a process over time, like acceleration, position etc. f(t). This is the ground truth that is happening.
Then we apply a measurement process in form m(t) = k*f(t)+b, where k is a scaling factor, and b is bias and noise combined. I assume that the noise is uniform, and with large enough data set will average out, so I don't care much about that.
For example I'm measuring rotation with n accelerometers at different lengths from the center of rotation. Then k would be the length from the center of rotation (plus minus all sorts of errors), and b would be bias terms, like gravity etc. Bur for now let's concentrate on the 1D case for simplicity.
If we have n measurements, each would have their own scaling factors and biases, is there a way of getting them (relative or absolute) extracted from the data?
Thus far I've gotten relative scaling factors out while testing, by numerically differentiating the data, and then comparing the differentiated functions to first one, and then averaging the result. I assume this works because differentiation gets rid of constants, but how would I approach getting out the bias terms?
I haven't gotten any good enough solutions, but I've tried to compute the following for the biases:
For n=2 measurements:
m1(t) = k1 * f(t) + b1
m2(t) = k2 * f(t) + b2
m2(t) - m1(t) = f(t) * (k2 - k1) + b2 - b1
If we make the assumption that b1 = 0, then we get relative (I think) bias between the two functions, and solving for b2 yields:
b2 = m2(t) - m1(t) - f(t) * (k2 - k1)
And if we are going with relative bias, we can assume that m1(t) == f(t) and getting us:
b2 = m2(t) - m1(t)*(k2 - k1 + 1)
This is assuming I didn't do any mistakes in calculation. If this is the case I have problem in implementation, but that is more trivial to solve than wrong thinking process.

Find a scalar to make a vector addition positive

I have two vectors a=(a_1, a_2,...,a_n) and b=(b_1, b_2,...,b_n). I want to find a scalar "s" such that s=max{s : a+sb >= 0}. Here inequality is elementwise i.e. a_i+sb_i>=0 for all i=[1,...,n]. How to compute such a scalar ? Also if s=infinity is the solution, we will bound s by s=1.
Also vector "a" is nonnegative (i.e. each element is >=0).
Okay so with a_i >= 0, we can see that s=0 is always a solution.
One possible way is to solve the inequality on all components and then take the intersection of the domains. Their upper bound (which, if finite, is part of the intersection) is then your wanted number.
that means:
is what you're trying to solve. Note that, because in the second case b_i is negative, the number on the right hand side is positive. That means the intersection of all s_i you get like this is non-empty. The maximum has a lower bound of 0, so technically you can ignore the inequalities where b_i is positive, they are true anyways. But, for completeness and illustration purposes:
Example:
a= (1,1), b=(-0,5,1)
1 - s*0.5 >= 0 , that means s <= 2, or s in (-inf, 2]
1 + s*1 >= 0, that means s>= -1, or s in [-1,inf)
intersection: [-1,2]
That means the maximum value such that both equations hold is 2.
That is the most straight-forward way, of course there are probably more elegant ways.
Edit: As algorithm: check if b_i is positive or negative. If positive, save s_i = 1 (if you want your value to be bound by one). If negative, save s_i = -a_i/b_i. In the end you want to actually take the minimum!
But more efficient: You don't actually need to care when b_i is positive. Your maximum will be greater or equal than zero anyways. So just check the cases where it is smaller than 0 and keep the minimum of them -a_i/b_i, as that is the upper bound of the region.
Pseudocode:
s = 1
for i in range = 1 to length(b):
if b[i]<0:
s = min(s, -a[i]/b[i])
Why the minimum? Because that -a[i]/b[i] is the upper bound of the region.

Simple 2 or 3 parameters float PRNG formula that changes faster than the float resolution and produces white noise?

I'm looking for a 2 or 3 parameters math formula with the following characteristics:
Simple (the fewest amount of operations the better)
Random output (non-periodic)
Normalized (Meaning the output will never be outside a given range; doesn't matter the range since once I know the range I can just divide and add/subtract to get it into the 0 to 1 range I'm looking for)
White noise (the more samples you get the more evenly distributed the outputs get across the range of possible output values, with no gaps or hotspots, to the extent permitted by the floating-point standard)
Random all the way down (no gradual changes between output values even if the inputs are changed by the smallest amount the float standard will allow. I understand that given the nature of randomness, it is possible two output values might be close together once in a while, but that must only happen by coincidence, and not because of smoothness or periodicity)
Uses only the operations listed bellow (but of course, any operations that can be done by a combination of the ones listed bellow are also allowed)
I need this because I need a good source of controllable randomness for some experiments I'm doing with Cycles material nodes in Blender. And since that is where the formula will be implemented, the only operations I have available are:
Addition
Subtraction
Multiplication
Division
Power (X to the power of Y)
Logarithm (I think it's X Log Y; I'm not very familiar with the logarithm operation, so I'm not 100% sure if that is enough to specify which type of logarithm it is; let me know if you need more information about it)
Sine
Cosine
Tangent
Arcsine
Arccosine
Arctangent (not Atan2, but that can be created by combining operations if necessary)
Minimum (Returns the lowest of 2 numbers)
Maximum (Returns the highest of 2 numbers)
Round (Returns the closest round number to the input)
Less-than (Returns 1 if X is less than Y, zero otherwise)
Greater-than (Returns 1 if X is more than Y, zero otherwise)
Modulo (Produces a sawtooth pattern of period Y; for positive X values it's in the 0 to Y range, and for negative values of X it's in the -Y to zero range)
Absolute (strips the sign of the input value, makes it positive if it was negative, doesn't do anything if it's already positive)
There is no iteration nor looping functionality available (and of course, branching can only be done by calculating all the branches and then doing something like multiplying the results of the branches not meant to be taken by zero and then adding the results of all of them together).

Varience of angles

I would like to calculate the variance of angles.
The problem is that angels are cyclic.
Variance{0°,0°,0°,0°,360°,360°,360°,360°} = 32400 - should be 0.
Variance{0°,0°,0°,0°,90°,90°,90°,90°} = 2025 - correct.
You get the idea...
Is there a proper way to compute this?
The typical moments you know about (expectation, (co)variance, etc.) are defined for random variables whose support is Euclidean space (Rn). Your random variables support is not Euclidean space. Expectation and variance are not defined (at least not in the usual way).
Take for example this set: { 0, π, 0, π, 0, π, ... }. These are 2N samples of the random angle variable A. What is the expectation of A, E[A]? π/2 or 3π/2?
You need to adjust your question to make sense, either by asking for something different, or by explicitly defining what you mean by variance.
You cannot do this directly. This because with angles 0=360 and such.
What I have done before is do statistics on points (x,y) = (COS(φ),SIN(φ)) and then converting back to angle with φ = ATAN2(y, x).
The usual way is to convert the angles to complex numbers on the unit circle, average them, and take the argument as the average angle. This gives you the mean angle, from which you can compute the variance normally (but remember to add or subtract 360 degrees until the difference is in the range (-180 degrees, 180 degrees) before squaring).

Resources