# right statistical test

#### Ell

##### New Member
Hello,

I'm looking for the right statistical test for comparing some results I got after repeating a task with 3 different set ups.
The measuraments are based on kinematics, so I have an array of x,y,z of my ideal trajectory (green line) and arrays of x,y,z of the real trajectory (purple line) for each set up.
Something like that: The goal is to compare the same task done by different users with the 3 different set ups in order to chose the one that guarantees the best performance (in terms of time and error).
I have found in the literature that the most used one is the t test and the ANOVA test.
Can you explain me please how should I proceed and if they are the right one in my case?
Thanks

#### Miner

##### TS Contributor
I will confess that this is outside of my field, and I have not encountered something like this before. The first thing that comes to mind is to convert your XYZ data into polar deviations from the ideal trajectory then use 1-way ANOVA to see whether there is a difference between the 3 setups. I would look at which setup was closest to zero as well as which had the least variation. It is usually easier to shift the mean than it is to reduce variation, so if you find one setup with less variation, you might be able to modify it to move it closer to zero.

#### Ell

##### New Member
First of all, thanks for the reply!
I was thinking that maybe I can evaluate the error between the real and the ideal path for the three set ups and then use the anova to compare them as set up 1 vs set up 2 and soon. Finally the one that gives me the lowest p value should be the best one.
am I right?

#### Miner

##### TS Contributor
ANOVA will tell you whether there is a difference between 3 or more setups. It will not tell you which setup is the best. If the difference is statistically significant, you will have to determine which is best by other criteria such as the smallest mean, the least variation, etc. If there is no difference, then the setups are either equivalent, or the test was underpowered (sample size too small).

#### katxt

##### Active Member
It seems that the actual statistical analysis should be comparatively straight forward. I imagine that your main problem will be devising a suitable measure for the goodness of a particular path to put into your anova.
It looks like your data is in three dimensions.
A very simple measure of goodness, both to understand and to calculate, is the total length of the path, which can be calculated directly from the xyz data. I would start with that.
Another more statistical measure would be the average closeness (the average distance from the target line). Miner's suggestion (I think) is average deviation from the line. This is more complicated to calculate and there may be problems when the line is moving backwards.
In engineering, the average deviation is often found using RMS (root mean square). Both these last two would be easier to calculate if you rotated the data one line at a time so that the line was oriented along one axis.

#### Ell

##### New Member
I don't get how the total length of the path should help me evaluate the goodness of my data. I would use the error such as the deviation from the line as you suggested. Can you also explain what do you mean by rotating the data?
Moreover should I perform the ANOVA test for each coordinates separately?
Thanks

Last edited:

#### katxt

##### Active Member
I don't get how the total length of the path should help me evaluate the goodness of my data.
I have no special knowledge in kinematics so my ideas will be simple guesses. My idea is that if the length of the green lines are, say 1 m, then a path length of 1.1 m along one side must be quite close to the line, while if the path length is 2.5 m then they have obviously wandered about lot. As a measure it's crude but easy. Short paths are better than long paths.
Moreover should I perform the ANOVA test for each coordinates separately?
If the three sides of the triangle have separate special significance in your experiment, you could make that a separate factor and have a two way anova. Otherwise I imagine you could use the total path length. The analysis is the easy part.
Both these last two would be easier to calculate if you rotated the data one line at a time so that the line was oriented along one axis.
Because you use xyz, I imagine that the paths and lines are in three dimensions. If part of your analysis is to calculate the distance of a particular point to the appropriate line then this requires some 3d geometry. If you are into vector analysis the a site like https://onlinemschool.com/math/library/analytic_geometry/p_line/ will give you the formulas.
If not then your work can be simplified by transforming the data with a program or spreadsheet. and some comparatively simple formulas. Shift all the data points so that one end of the line is at zero. Rotate all the points round the z axis until the line falls in the xy plane. Then rotate round the y axis until the line falls on the x axis. Now any distance to the line (x axis) is just Pythagoras.
If this make no sense you may need to find an engineer or mathematician to help. kat

#### Ell

##### New Member
Got it! I'll try and let you know.
Thanks for all the advices!!

#### katxt

##### Active Member
I just had another look at the vector stuff and it isn't as bad as I remembered it. Subtract the side start from the side and every point on the path. The side now starts at (0,0,0) and ends at say (sx,sy,sz). Each point has new coordinates, point p (px,py,pz).
D is the shortest distance from the point p to the line
D^2=[(px.sy-sx.py)^2+(py.sz-sy.pz)^2+(pz.sx-sz.px)^2]/[px^2+py^2+pz^2] (There's a pattern there.)
then D is the square root of that.