Calculate root Mean Squared for short array - Android java.lang

Android examples for java.lang:array

Description

Calculate root Mean Squared for short array

Demo Code

import android.content.Context;
import android.content.pm.PackageManager;
import android.media.MediaRecorder;
import android.os.Environment;
import android.util.Log;
import java.io.IOException;
import java.io.PrintWriter;

public class Main{

    public static double rootMeanSquared(short[] nums) {
        double ms = 0;
        for (int i = 0; i < nums.length; i++) {
            ms += nums[i] * nums[i];// w  w  w. j ava 2  s .  co m
        }
        ms /= nums.length;
        return Math.sqrt(ms);
    }

}

Related Tutorials