View Javadoc
1   /*** PlateView.java - part of the MirkE (say murky) application for colormetric analysis emphesizing 
2   kinetics.
3   
4   Created by: Scott Menor on 21 July, 2004.
5   Last modified by: Scott Menor on 12 December, 2004
6   
7   Copyright (c) 2004 Arizona State University - Cancer Research Institute. All rights reserved.
8   
9   MirkE is free software; you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation; either version 2 of the License, or
12  (at your option) any later version.
13  
14  MirkE is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  GNU General Public License for more details.
18  
19  You should have received a copy of the GNU General Public License
20  along with MirkE; if not, write to the Free Software
21  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  US
22  */
23  
24  package edu.asu.cri.MirkE.util;
25  
26  import java.util.*;
27  import edu.asu.cri.MirkE.MirkE;
28  
29  /***
30  
31  */
32  public abstract class DataAnalyzer {
33  	/*** <code>MirkE</code> instance associated with a <code>DataAnalyzer</code> instance
34  	
35  	*/
36  	private MirkE mirke;
37  		
38  	/***
39  	
40  	 @param mirke
41  	 */
42  	public void setMirke(MirkE mirke) {
43  		this.mirke = mirke;
44  	}
45  	
46  	/***
47  		
48  	 @return mirke
49  	 */
50  	public MirkE getMirke() {
51  		return mirke;
52  	}	
53  	
54  	/***
55  	
56  	 @param list <code>java.util.List</code> of <code>Double</code>s
57  	 @param mean the mean value of the <code>Double</code>s in <code>list</code> note - if <code>mean<code> is not the mean value of the items in the list, this will return the second moment of the distribution about the value of <code>mean</code>
58  	 
59  	 @return stdev standard deviation from the mean
60  	 */
61  	public static double stdevFromListAndMean(java.util.List list, double mean) {
62          // TODO - compute stddev and average using SQL group commands
63  		double stdev = 0d;
64  		
65  		if (list.size() > 1) {
66  			Iterator listIterator = list.iterator();
67  			while (listIterator.hasNext()) {
68  				double value = ((Double)listIterator.next()).doubleValue();
69  				stdev += Math.pow(value - mean, 2);
70  			}
71  			
72  			stdev /= list.size();
73  			
74  			stdev = Math.sqrt(stdev);			
75  		} else {
76  			stdev = Double.NaN;
77  		}
78  		
79  		return stdev;
80  	}
81  }