LightJason - AgentSpeak(L++)
EStatisticValue.java
Go to the documentation of this file.
1 /*
2  * @cond LICENSE
3  * ######################################################################################
4  * # LGPL License #
5  * # #
6  * # This file is part of the LightJason AgentSpeak(L++) #
7  * # Copyright (c) 2015-19, LightJason (info@lightjason.org) #
8  * # This program is free software: you can redistribute it and/or modify #
9  * # it under the terms of the GNU Lesser General Public License as #
10  * # published by the Free Software Foundation, either version 3 of the #
11  * # License, or (at your option) any later version. #
12  * # #
13  * # This program is distributed in the hope that it will be useful, #
14  * # but WITHOUT ANY WARRANTY; without even the implied warranty of #
15  * # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
16  * # GNU Lesser General Public License for more details. #
17  * # #
18  * # You should have received a copy of the GNU Lesser General Public License #
19  * # along with this program. If not, see http://www.gnu.org/licenses/ #
20  * ######################################################################################
21  * @endcond
22  */
23 
24 package org.lightjason.agentspeak.action.builtin.math.statistic;
25 
26 import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
27 import org.apache.commons.math3.stat.descriptive.SummaryStatistics;
29 
30 import javax.annotation.Nonnull;
31 import java.util.Locale;
32 
33 
37 public enum EStatisticValue
38 {
40  MAX,
41  MIN,
47  SUM,
53 
60  @Nonnull
61  public static EStatisticValue from( @Nonnull final String p_value )
62  {
63  return EStatisticValue.valueOf( p_value.trim().toUpperCase( Locale.ROOT ) );
64  }
65 
72  public final double value( @Nonnull final SummaryStatistics p_statistic )
73  {
74  switch ( this )
75  {
76  case GEOMETRICMEAN:
77  return p_statistic.getGeometricMean();
78 
79  case MAX:
80  return p_statistic.getMax();
81 
82  case MIN:
83  return p_statistic.getMin();
84 
85  case COUNT:
86  return p_statistic.getN();
87 
88  case POPULATIONVARIANCE:
89  return p_statistic.getPopulationVariance();
90 
91  case QUADRATICMEAN:
92  return p_statistic.getQuadraticMean();
93 
94  case SECONDMOMENT:
95  return p_statistic.getSecondMoment();
96 
97  case STANDARDDEVIATION:
98  return p_statistic.getStandardDeviation();
99 
100  case SUM:
101  return p_statistic.getSum();
102 
103  case SUMLOG:
104  return p_statistic.getSumOfLogs();
105 
106  case SUMSQUARE:
107  return p_statistic.getSumsq();
108 
109  case VARIANCE:
110  return p_statistic.getVariance();
111 
112  case MEAN:
113  return p_statistic.getMean();
114 
115  default:
116  throw new CIllegalStateException( org.lightjason.agentspeak.common.CCommon.languagestring( this, "unknown", this ) );
117  }
118  }
119 
126  public final double value( @Nonnull final DescriptiveStatistics p_statistic )
127  {
128  switch ( this )
129  {
130  case GEOMETRICMEAN:
131  return p_statistic.getGeometricMean();
132 
133  case MAX:
134  return p_statistic.getMax();
135 
136  case MIN:
137  return p_statistic.getMin();
138 
139  case COUNT:
140  return p_statistic.getN();
141 
142  case POPULATIONVARIANCE:
143  return p_statistic.getPopulationVariance();
144 
145  case QUADRATICMEAN:
146  return p_statistic.getQuadraticMean();
147 
148  case STANDARDDEVIATION:
149  return p_statistic.getStandardDeviation();
150 
151  case SUM:
152  return p_statistic.getSum();
153 
154  case SUMSQUARE:
155  return p_statistic.getSumsq();
156 
157  case VARIANCE:
158  return p_statistic.getVariance();
159 
160  case MEAN:
161  return p_statistic.getMean();
162 
163  case KURTIOSIS:
164  return p_statistic.getKurtosis();
165 
166  default:
167  throw new CIllegalStateException( org.lightjason.agentspeak.common.CCommon.languagestring( this, "unknown", this ) );
168  }
169  }
170 }
final double value( @Nonnull final DescriptiveStatistics p_statistic)
returns a statistic value
static< T > String languagestring(final T p_source, final String p_label, final Object... p_parameter)
returns the language depend string on any object
static EStatisticValue from( @Nonnull final String p_value)
additional factory
final double value( @Nonnull final SummaryStatistics p_statistic)
returns a statistic value