Why does this cascade of projection not change the projecton result? - relational-database

From Database System Concept:
Only the final operations in a sequence of projection operations are
needed; the others can be omitted. This transformation can also be
referred to as a cascade of projection.
Why does the above equation hold?
If L2 isn't a super set of L1, doesn't the left hand side have less columns than the right hand side?
Thanks.

Why does the above equation hold?
A projection's attribute set must be a subset of its argument's. So each left hand side set is a subset of the set to its right. Each projection keeps some of its argument's columns. Finally only the leftmost set is left. That gives the right hand side.
If you wrote out the equation clearly saying what E & the Ls are then the restrictions would be apparent.
If L2 isn't a super set of L1, doesn't the left hand side have less columns than the right hand side?
L2 must be a superset of L1. Otherwise the left hand side is undefined.

Related

What is the effect of a row of zeros in singular value decomposition?

I am writing some CUDA code for finding the 3 parameters of a circle (centre X,Y & radius) from many (m) measurements of positions around the perimeter.
As m > 3 I am (successfully) using Singular Value Decomposition (SVD) for this purpose (using the cuSolver library). Effectively I am solving m simulaneous equations with 3 unknowns.
However, not all of my perimeter positions are valid (say q of them), and so I have to go through my initial set of m measurements and remove the q invalid ones. This involves moving the size m data array from the card to the host, processing linearly to remove the q invalid entries and then re loading the smaller (m-q) array back onto the card...
My question is; if I were to set all terms on both sides of the q invalid equations to zero, could I just run the m equations (including the zeros) through my SVD analysis (without the data transfer etc) or would this cause other problems?
My instinct tells me that this is a bit like applying weights to the data but instinct and SVD are not terms that sit well together in my experience...
I am hesitant just to try this as I don't know if it will work in some cases and not in others...
I have tested the idea by inserting rows of zeros into my matrix. The solution that I am getting is not significantly affected by this.
So I am answering my own question with a non-rigorous Yes it is OK do do this.
If anybody has a more rigorous or more considered answer I would very much like to hear it.

Regression of Continuous variable on nominal variables

Using JMP software, if my dependent variable on the y-axis is a continuous variable "Revenue from Movie" and the predictors are 4 categorical variables ( 1= Action, 2=Comedy, 3 = Kids, 4=Other) then I find that the JMP software always leaves one of the 4 categorical variables out in the regression output.
The least squares mean of the left out variable becomes the intercept on y-axis and then every other regression co-efficient is interpreted with respect to this intercept (the least squares mean of the left out variable). In some way, I see this gives the same information with fewer variables because the R-square does not change but why does it work this way. That's what I dont understand. How come everything is interpreted with respect to what we left out and we still have the same R-square.
In this image, we left out "Kids" so its least squares mean becomes the intercept and then Action = 56.66 - 45.10 = 11.56 and so on

manipulation of equations in maxima

I searched the maxima manual about how to manipulate the equation and the likes but I can't really find it.
I've already implemented coefmatrix in terms of ratcoef and using lhs and rhs. To finish it and proceed to augmented part, I need to know how to do this.
How can I make this:
x + 10 - y = z + 5;
turn into this:
x - y - z = -5;
There are a couple of ways to do it. (1) I assume that you have already figured out how to get the coefficients via ratcoef and the right-hand side via rhs. Let foo be the right-hand side minus the left-hand side (so now you have right - left = 0. Subtract the sum of all the variables times their coefficients from that. Then the remainder is the constant part that doesn't depend on any variable. (2) Use freeof to identify terms which are free of (i.e., do not contain) any variable.

Direction vs sign of bitwise shift/rotation

For bit-wise shift (or rotation, circulation) operations, we usually have an operator, i mean two of them, for instance
x << n
x >> n
for left or right shift of x by n bits.
We want to define a single function
bitshift(x, n)
Before that, we have to determine, which shift is to be used for positive and negative n - what is the "sign" of each shift (or rotation) direction.
Is there a definition or convention for that?
(Please note that this question has nothing to do with signed/unsigned types)
UPDATES
Please also note that i am not asking for implementation details of this function, even it might be somewhat related..
There are similar functions in scheme/lisp-like languages, like ash, which do left shift for positive n
Since shifting right by k places is equal to multiplying by 2^-k, and shifting left is equal to multiplying by 2^k, I think that should give you a hint.
Note: Reason I would argue for this way of looking at it is that it is common to consider multiplication as more fundamental operation in some sense than division is, although you could certainly argue the other way around.
You can use negative number as argument
For example
x << n
so pass n=2 if yuo want to left shift two positions
and pass n=-2 if you want to right shift two positions.

How to implement dead reckoning when turning is involved?

"Dead reckoning is the process of estimating one's current position based upon a previously determined position and advancing that position based upon known or estimated speeds over elapsed time, and course." (Wikipedia)
I'm currently implementing a simple server that makes use of dead reckoning optimization, which minimizes the updates required by making logical assumptions on both the clients and the server.
The objects controlled by users can be said to be turning, or not turning. This presents an issue with dead reckoning (the way I see it.)
For example, say you have point A in time defined by [position, velocity, turning: left/right/no]. Now you want point B after t amount of time. When not turning, the new position is easy to extrapolate. The resulting direction is also easy to extrapolate. But what about when these two factors are combined? The direction of the velocity will be changing along a curve as the object is turning over t amount of time.
Should I perhaps go with another solution (such as making the client send an update for every new direction rather than just telling the server "I'm turning left now")?
This is in a 2D space, by the way, for the sake of simplicity.
For simplicity let's say that your vehicles have a turning radius r that's independant of speed. So to compute the new position given the initial coords and the time:
compute the distance (that's velocity * time)
compute how much you turned (that's distance / (2*pi*r))
add that arc to the original position.
The last steps needs elaboration.
Given the angle a computed in step 2, if you started at (0,0) with a due north heading (i.e. pi/2 radians) and are turning left then your new positions is: (rcos(a)-1, rsin(a)).
If your original heading was different, say it was "b", then simply rotate the new position accordingly, i.e. multiply by this rotation matrix:
[ cos b , -sin b ]
[ sin(b), cos(b) ]
Finally, add the initial position and you're done. Now you only need to send an update if you change the velocity or turning direction.
Well, I think "turning: left/right/no" is insufficient to determine position B - you also need to know the arc at which the turn is being made. If you are turning left along a circular path of radius 1, you will end up at a different place than if you are turning along a circular path of radius 10, even though your initial position, velocity, and direction of turn will all be the same.
If making the client send an update for every new direction and treating them as linear segments is an option, that is going to be a much easier calculation to make. You can simply treat each new report from the client as a vector, and sum them. Calculating a bunch of curves is going to be more complex.