-
Notifications
You must be signed in to change notification settings - Fork 0
/
Values.java
64 lines (39 loc) · 950 Bytes
/
Values.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import java.util.ArrayList;
/**
*
* @author jashanjotsingh
*
* This class provides the values required to calculate correlation among x and y.
*
*/
public class Values {
public double Mean(ArrayList<Double> ar){
double mean , sum =0;
for (Double ar1 : ar) {
sum = sum + ar1;
}
mean = sum/ar.size();
return mean;
}
public double deviation_sqaured(ArrayList<Double> ar, double mean){
double diff=0;
for (Double ar1 : ar) {
diff = diff + ((ar1 - mean) * (ar1 - mean));
}
return diff;
}
public double deviations_product(ArrayList<Double> ar1,ArrayList<Double> ar2, double xmean, double ymean){
double product=0;
if(ar1.size()==ar2.size()){
for(int i=0;i<ar1.size();i++){
product = product + ((ar1.get(i)-xmean)*(ar2.get(i)-ymean));
}
}
return product;
}
public double Correlation(double o1,double o2,double o3){
double r;
r = o1/(Math.sqrt(o2*o3));
return r*r;
}
}