I am working on an android application which detect the hand shaking (through accelerometer) and it modulates the vibration frequency based on shaking intensity.
I am able to get the tremor intensity through standard deviation (code below):
public void regressionCalc() {
//Calculating sum values
double sumZ;
double meanZ;
sumZ = 0;
final TextView accZText = (TextView) findViewById(R.id.accelText);
accZText.setText("");
for (int r = 0; r < recArray.length; r++) {
sumZ = sumZ + recArray[r];
}
meanZ = sumZ/recArray.length;
//Calculating standard deviation
double sumXu2; //this represents E((x-xbar)^2)
sumXu2 = 0;
for (int x = 0; x < recArray.length; x++) {
sumXu2 += ((recArray[x]-meanZ)*(recArray[x]-meanZ));
}
double SD;
SD = Math.sqrt(sumXu2/(recArray.length-1));
tremorIntensity = SD;
accZText.setText(String.format("%.2f", tremorIntensity) + "");
accZText.setTextSize(80);
}
but I don't know how to work with vibration. I mean, I would like the phone vibration intensity decrease or increase based on the regression value.
Could anyone address me to a correct way? Thanks in advance.