Statisics - linearity and best-fit in 3 dimensions

No, I am not interested in motion parallel to a tilted axis. Your understanding of my use of origin is also I think correct - in fact one operating mode of the gesture-tracking package specifically locks the coordinate system to body centroid and calculates all distances from there. So, to be absolutely accurate, origin should not be the feet but around waist level. However, a better solution would set origin from initial joint position - therefore, for any joint origin is set to first detected position in world coordinate system. This is again wishful thinking - if it overcomplicates the problem by all means pick a set origin around waist/navel level and go from there.

Recognitions:
I'm having a hard time visualizing any practical problem where one would only care about motion parallel to one of the coordinate axes!

In an earlier post, you said
 The simplest solution I could come up with is to detect individual motions parallel to the axes (over a limited set of datapoints), then use start and end end points to determine direction
Is the direction that is determined by the start and end points always to be a direction that is parallel to one of the coordinate axes?
 Well, after we have tested to see if they are indeed parallel then yes. In that post by direction I meant towards or away from origin. Sorry if that was unclear Re application, think of a mouse or a keyboard. A "click" or "keystroke" only "moves" in one direction. Think of the 6 possible motions (3 axes, 2 directions) as 6 keystrokes. As I said, the 2d recognizer requires an init event to begin gathering data for recognition. The parallel motions will serve as init events.
 I'd say using Pearson's r is not a good idea, for example, if a line is parallel to one of the axis you use to calculate it the correlation will be zero. A PCA answers all your three questions at once, if it is a line you will have only one significant eigenvalue and its eigenvector will tell you if its parallel or not to any axis. For more info: http://en.wikipedia.org/wiki/Princip...onent_analysis
 I have had pca suggested to me before. Could you please give an expression involving sums but not integrals or derivative, as the environment I'm working with does not support them? I have been unable to make my way through the wiki article (freshman calc etc). Also, apologies in advance if this involves matrices and I ask some rookie questions - my matrix skills are kinda weak. Thanks again Joe

Recognitions:
 Quote by jamesson Re application, think of a mouse or a keyboard. A "click" or "keystroke" only "moves" in one direction. Think of the 6 possible motions (3 axes, 2 directions) as 6 keystrokes.
OK, I'm going to think of someone giving hand signals to an equipment operator. The one's you want to recognize are left, right, up, down, forward , backward.

The way I'm visualizing the data at present is that you not only have the problem of applying some test to a set of data, you have the problem of picking which sets of data to analyze. If I think of the data as a long series of vectors (x1,y1,z1,t1), (x2,y2,z2,t2).....(xn,yn,zn,tn) then this sequence may contain several different gestures. So you must picked out various "windows" of data to analyze. The data from t10 to t200 might be one gesture and the data from t315 to t390 might be another. Am I correct that picking out sequences of data is part of the problem? Have you solved that part of it already?

Should we think of this as a non-real time system where we can scan back and forth in all the data? Or must the system work in roughly real time as data is coming in?
 Your concept of "hand signals" is accurate, however selection of windows (if I understand you correctly) is inherently not part of the problem. Once an "init" "hand signal" is received we assume that whatever follows is a 2d gesture. All 2d gestures consist of an arbitrary (but equal) number of datapoints which are compared to a prerecorded library of gestures in realtime. The software then identifies the gesture (there is a tolerance value which tells the software how closely the input gesture must match the recorded gesture). Recording of 2d data continues until the "stop" "hand signal" is received. The "stop" "hand signal" is nothing more than the "init" "hand signal" reversed; that is to say whereas The "begin gesture" (init) "hand signal" moves away from the origin, the "stop" "hand signal" moves toward the origin along the same axis as the "init". When "stop" is received any points beyond the arbitrary preset length are discarded and 2d recognition occurs. I am not yet 100% sure I will need a stop (I may simply trigger recognition when the requisite number of points is received) but far easier to build it and not use it than try to build it later. Example; 1) user moves hand up 2) 2d datapoint recording begins on the xz plane 3) user moves hand down or requisite length of xz dataset is reached 4) recognition occurred, result is handled, gesture listener resets. Re realtime, most definitely realtim Thanks again

 Quote by jamesson I have had pca suggested to me before. Could you please give an expression involving sums but not integrals or derivative, as the environment I'm working with does not support them?... Joe
What is that environment?
 Max MSP
 the tutorial article wikipedial links to is actually far ,ore soothing than wikipedia itself. I may give it a shot later tonight.

 Quote by jamesson Max MSP
Oh I see, about music?, OK, obviously your best choice would be to find some libraries that you might use from Max MSP to calculate the PCA, but if that is not an option, I would say that the chapter Computing principal components efficiently in the wiki link is pretty much what you need. It gives you a way to calculate the PCA with an iterative computation which only uses products and sums. And in your case you don't even need to calculate all eigenvalues and vectors.

I'm sure Max MSP should be able to deal with that one...

Good luck though!!
 Don't know when I will get to try this way, but hopefully soon, and I definitely will need help. Thanks again.

 Quote by jamesson Don't know when I will get to try this way, but hopefully soon, and I definitely will need help. Thanks again.
You're welcome, but hey, post a video with this project, it looks pretty interesting!
 Recognitions: Science Advisor Let's discuss an utterly simple method. Perhaps objections to it will clarify the problem further. Let the data points be $(x_i,y_i,z_i,t_i)$ for $i = 1$ to $N$. If this data represented a line perfectly parallel to the y axis then the $x$ and $z$ values would remain constant while the $y$ value varied. If we have data from an imperfect line, we could estimate the line that the data is "trying to" follow in various ways. The simplest seems to be to estimate that the $\hat{x} =$ the average of the $x$ values in the data and $\hat{z} =$ the average of the $z$ values. We can quantify the "error" that the imperfect data has in various ways. The one that comes to my mind first $$\hat{\sigma^2} = (\frac{1}{N}) { \sum_{i=1}^N ( (\hat{x} - x )^2 + (\hat{z}-z)^2)}$$ Of course the idea is to classify the data as a gesture parallel to the y axis when $\hat{\sigma^2}$ is "small". What constitutes a small or large error would have to be determined empirically. You'd have to do a different test for each axis, but this is not an elaborate computation. One weakness of this method is that it doesn't give any more credit to data that is a perfect straight line but slightly out-of-parallel vs data that is scattered. Is this weakness the reason that you are considering sophisticated statistical methods?