1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 package org.apache.commons.math.stat.descriptive; 18 19 import org.apache.commons.math.DimensionMismatchException; 20 import org.apache.commons.math.linear.RealMatrix; 21 22 /** 23 * Implementation of 24 * {@link org.apache.commons.math.stat.descriptive.MultivariateSummaryStatistics} that 25 * is safe to use in a multithreaded environment. Multiple threads can safely 26 * operate on a single instance without causing runtime exceptions due to race 27 * conditions. In effect, this implementation makes modification and access 28 * methods atomic operations for a single instance. That is to say, as one 29 * thread is computing a statistic from the instance, no other thread can modify 30 * the instance nor compute another statistic. 31 * @since 1.2 32 * @version $Revision: 618097 $ $Date: 2008-02-03 22:39:08 +0100 (dim., 03 févr. 2008) $ 33 */ 34 public class SynchronizedMultivariateSummaryStatistics 35 extends MultivariateSummaryStatistics { 36 37 /** Serialization UID */ 38 private static final long serialVersionUID = 7099834153347155363L; 39 40 /** 41 * Construct a SynchronizedMultivariateSummaryStatistics instance 42 * @param k dimension of the data 43 * @param isCovarianceBiasCorrected if true, the unbiased sample 44 * covariance is computed, otherwise the biased population covariance 45 * is computed 46 */ 47 public SynchronizedMultivariateSummaryStatistics(int k, boolean isCovarianceBiasCorrected) { 48 super(k, isCovarianceBiasCorrected); 49 } 50 51 /** 52 * @see org.apache.commons.math.stat.descriptive.MultivariateSummaryStatistics#addValue(double[]) 53 */ 54 public synchronized void addValue(double[] value) 55 throws DimensionMismatchException { 56 super.addValue(value); 57 } 58 59 /** 60 * @see org.apache.commons.math.stat.descriptive.MultivariateSummaryStatistics#getDimension() 61 */ 62 public synchronized int getDimension() { 63 return super.getDimension(); 64 } 65 66 /** 67 * @see org.apache.commons.math.stat.descriptive.MultivariateSummaryStatistics#getN() 68 */ 69 public synchronized long getN() { 70 return super.getN(); 71 } 72 73 /** 74 * @see org.apache.commons.math.stat.descriptive.MultivariateSummaryStatistics#getSum() 75 */ 76 public synchronized double[] getSum() { 77 return super.getSum(); 78 } 79 80 /** 81 * @see org.apache.commons.math.stat.descriptive.MultivariateSummaryStatistics#getSumSq() 82 */ 83 public synchronized double[] getSumSq() { 84 return super.getSumSq(); 85 } 86 87 /** 88 * @see org.apache.commons.math.stat.descriptive.MultivariateSummaryStatistics#getSumLog() 89 */ 90 public synchronized double[] getSumLog() { 91 return super.getSumLog(); 92 } 93 94 /** 95 * @see org.apache.commons.math.stat.descriptive.MultivariateSummaryStatistics#getMean() 96 */ 97 public synchronized double[] getMean() { 98 return super.getMean(); 99 } 100 101 /** 102 * @see org.apache.commons.math.stat.descriptive.MultivariateSummaryStatistics#getStandardDeviation() 103 */ 104 public synchronized double[] getStandardDeviation() { 105 return super.getStandardDeviation(); 106 } 107 108 /** 109 * @see org.apache.commons.math.stat.descriptive.MultivariateSummaryStatistics#getCovariance() 110 */ 111 public synchronized RealMatrix getCovariance() { 112 return super.getCovariance(); 113 } 114 115 /** 116 * @see org.apache.commons.math.stat.descriptive.MultivariateSummaryStatistics#getMax() 117 */ 118 public synchronized double[] getMax() { 119 return super.getMax(); 120 } 121 122 /** 123 * @see org.apache.commons.math.stat.descriptive.MultivariateSummaryStatistics#getMin() 124 */ 125 public synchronized double[] getMin() { 126 return super.getMin(); 127 } 128 129 /** 130 * @see org.apache.commons.math.stat.descriptive.MultivariateSummaryStatistics#getGeometricMean() 131 */ 132 public synchronized double[] getGeometricMean() { 133 return super.getGeometricMean(); 134 } 135 136 /** 137 * @see org.apache.commons.math.stat.descriptive.MultivariateSummaryStatistics#toString() 138 */ 139 public synchronized String toString() { 140 return super.toString(); 141 } 142 143 /** 144 * @see org.apache.commons.math.stat.descriptive.MultivariateSummaryStatistics#clear() 145 */ 146 public synchronized void clear() { 147 super.clear(); 148 } 149 150 /** 151 * @see org.apache.commons.math.stat.descriptive.MultivariateSummaryStatistics#equals(Object) 152 */ 153 public synchronized boolean equals(Object object) { 154 return super.equals(object); 155 } 156 157 /** 158 * @see org.apache.commons.math.stat.descriptive.MultivariateSummaryStatistics#hashCode() 159 */ 160 public synchronized int hashCode() { 161 return super.hashCode(); 162 } 163 164 /** 165 * @see org.apache.commons.math.stat.descriptive.MultivariateSummaryStatistics#getSumImpl() 166 */ 167 public synchronized StorelessUnivariateStatistic[] getSumImpl() { 168 return super.getSumImpl(); 169 } 170 171 /** 172 * @see org.apache.commons.math.stat.descriptive.MultivariateSummaryStatistics#setSumImpl(StorelessUnivariateStatistic[]) 173 */ 174 public synchronized void setSumImpl(StorelessUnivariateStatistic[] sumImpl) 175 throws DimensionMismatchException { 176 super.setSumImpl(sumImpl); 177 } 178 179 /** 180 * @see org.apache.commons.math.stat.descriptive.MultivariateSummaryStatistics#getSumsqImpl() 181 */ 182 public synchronized StorelessUnivariateStatistic[] getSumsqImpl() { 183 return super.getSumsqImpl(); 184 } 185 186 /** 187 * @see org.apache.commons.math.stat.descriptive.MultivariateSummaryStatistics#setSumsqImpl(StorelessUnivariateStatistic[]) 188 */ 189 public synchronized void setSumsqImpl(StorelessUnivariateStatistic[] sumsqImpl) 190 throws DimensionMismatchException { 191 super.setSumsqImpl(sumsqImpl); 192 } 193 194 /** 195 * @see org.apache.commons.math.stat.descriptive.MultivariateSummaryStatistics#getMinImpl() 196 */ 197 public synchronized StorelessUnivariateStatistic[] getMinImpl() { 198 return super.getMinImpl(); 199 } 200 201 /** 202 * @see org.apache.commons.math.stat.descriptive.MultivariateSummaryStatistics#setMinImpl(StorelessUnivariateStatistic[]) 203 */ 204 public synchronized void setMinImpl(StorelessUnivariateStatistic[] minImpl) 205 throws DimensionMismatchException { 206 super.setMinImpl(minImpl); 207 } 208 209 /** 210 * @see org.apache.commons.math.stat.descriptive.MultivariateSummaryStatistics#getMaxImpl() 211 */ 212 public synchronized StorelessUnivariateStatistic[] getMaxImpl() { 213 return super.getMaxImpl(); 214 } 215 216 /** 217 * @see org.apache.commons.math.stat.descriptive.MultivariateSummaryStatistics#setMaxImpl(StorelessUnivariateStatistic[]) 218 */ 219 public synchronized void setMaxImpl(StorelessUnivariateStatistic[] maxImpl) 220 throws DimensionMismatchException { 221 super.setMaxImpl(maxImpl); 222 } 223 224 /** 225 * @see org.apache.commons.math.stat.descriptive.MultivariateSummaryStatistics#getSumLogImpl() 226 */ 227 public synchronized StorelessUnivariateStatistic[] getSumLogImpl() { 228 return super.getSumLogImpl(); 229 } 230 231 /** 232 * @see org.apache.commons.math.stat.descriptive.MultivariateSummaryStatistics#setSumLogImpl(StorelessUnivariateStatistic[]) 233 */ 234 public synchronized void setSumLogImpl(StorelessUnivariateStatistic[] sumLogImpl) 235 throws DimensionMismatchException { 236 super.setSumLogImpl(sumLogImpl); 237 } 238 239 /** 240 * @see org.apache.commons.math.stat.descriptive.MultivariateSummaryStatistics#getGeoMeanImpl() 241 */ 242 public synchronized StorelessUnivariateStatistic[] getGeoMeanImpl() { 243 return super.getGeoMeanImpl(); 244 } 245 246 /** 247 * @see org.apache.commons.math.stat.descriptive.MultivariateSummaryStatistics#setGeoMeanImpl(StorelessUnivariateStatistic[]) 248 */ 249 public synchronized void setGeoMeanImpl(StorelessUnivariateStatistic[] geoMeanImpl) 250 throws DimensionMismatchException { 251 super.setGeoMeanImpl(geoMeanImpl); 252 } 253 254 /** 255 * @see org.apache.commons.math.stat.descriptive.MultivariateSummaryStatistics#getMeanImpl() 256 */ 257 public synchronized StorelessUnivariateStatistic[] getMeanImpl() { 258 return super.getMeanImpl(); 259 } 260 261 /** 262 * @see org.apache.commons.math.stat.descriptive.MultivariateSummaryStatistics#setMeanImpl(StorelessUnivariateStatistic[]) 263 */ 264 public synchronized void setMeanImpl(StorelessUnivariateStatistic[] meanImpl) 265 throws DimensionMismatchException { 266 super.setMeanImpl(meanImpl); 267 } 268 269 }