# Using my sensor values, what are relevant data analysis techniques?

I am currently trying to devise a system using gyroscope+accelerometers placed in on a hat/cap in certain areas of the head (Front-left, Front-right, Centre, Back-left, Back-right). I want to create a system that can determine if the hat is roughly worn incorrectly (ie misaligned, tilted to the side, backwards).

The experiment is to:

• measure sensor values(angles) when the hat is correctly worn and not in motion (rest)
• measure sensor values(angles) when the hat is correctly worn and in motion (nodding up and down, side-to-side)
• measure sensor values(angles) when the hat is Incorrectly worn in both not in motion and in motion.

I am asking is theres a suitable data analysis algorithm/technique to use these sensor values and essentially give a rough estimate if the hat is worn correctly or not.

IDEA #1

For sensing whether if the hat is worn correctly or not, you could try to glue the module in the youtube video below on to various sides of the hat (You should also put it on the top as well), and find the range of coordinates many individuals get when wearing the hat properly, then make them wear it at different angles (Try to pick many angles close to each other for better readings), and measure the new coordinates, and the difference/change in spatial and angular coordinates (minimum coordinates, maximum, average, etc) between the accepted "normal" and the different angle/coordinates.

If the difference between coordinates breaks a certain threshold when comparing a random position from the normal position, then someone isn't wearing the hat correctly.

You could use different LED's to light up if you notice a change in spatial coordinates and tilting angle of the board.

I know for baseball caps, if you wear it backwards, the board will definitely notice a lower z axis displacement compared to when it's worn at the sides or the front (assuming you place sensor/gyroscope at the front of the hat)

IDEA #2

Try making a system of equations, and getting the hat's coordinates when worn properly. If they stay the same for 5 seconds, then those are the coordinates that you should compare with. If someone rotates the hat, then the answer will converge to something different, and if the difference between the two solutions passes a certain threshold, then the hat is at a different angle. You can use the same data gathering process mentioned in IDEA #1

• Make sure to pick angles and positions that will actually change noticeably as you rotate the hat (preferably at a tilted surface of the hat) – Niroosh Ka Apr 30 '18 at 5:15
• From idea 1, If i understand correctly: 1. Obtain x/y/z coordinates when the multiple users are wearing cap correctly 2. Obtain x/y/z coordinates when users incorrectly wear the cap in multiple different, incorrect positions 3. Find the min, max, avg of test results in 2 4. Ensure { |(avg in 2) - (avg in 1)|> threshold } for correct fitment . Is the threshold just the median of the results in 2? – user187388 Apr 30 '18 at 10:06
• More or less. The threshold is the accepted difference calculated between the correct and the first incorrect angle/value. You can use the mean or median as the calculations; up to you :P. You pick a constant value for the threshold, and always compare the difference in average, median, or whatever you want between the difference in correct and incorrect position, and the threshold. Threshold always has to be bigger than the difference by the way; so flip the inequality sign. – Niroosh Ka Apr 30 '18 at 20:03
• Yep of course! Also, regarding Idea 2, how would you go about creating the system of equations? – user187388 May 1 '18 at 2:10
• Try making equations that have some parts with high rates of change (magnitude wise), and at some points, there is not much change. That way, the threshold range will be the range that doesn't have a very high slope. You can use 1 equation, but the more, the merrier. Preferably: polynomial equations under degree 5, or sin(x)/x = w.e. BTW, if my comments have been helping you, feel free to give me an upvote :). – Niroosh Ka May 1 '18 at 2:50