Skip to content

Commit 266cdec

Browse files
committed
Cognitive Foundry 3.3.0.
1 parent 0884fd9 commit 266cdec

File tree

307 files changed

+21062
-3048
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

307 files changed

+21062
-3048
lines changed

ChangeLog.txt

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,50 @@ This file contains the change log for the Cognitive Foundry.
22

33
Changes since last release:
44

5+
Release 3.3.0 (2011-06-22):
6+
* Common Core:
7+
* Added LogMath and LogNumber as utilities for computation involving numbers
8+
represented in log-space.
9+
* Added MutableInteger and MutableLong, which are like Integer and Long but
10+
with a mutable value, similar to MutableDouble.
11+
* UnivariateSummaryStatistics added.
12+
* Added DefaultIndentifiedValue.
13+
* Learning Core:
14+
* VectorNaiveBayesCategorizer: evaluateWithDiscriminant now properly
15+
normalizes the discriminant, which improves results for things like AUC.
16+
* PartitionalClusterer: Fixed corner-case bug.
17+
* Added confidence-weighted online learners based on variance, standard
18+
deviation, and AROW. They produce ConfidenceWeightedBinaryCategorizer
19+
objects with either diagonal or full covariance matrices.
20+
* Added balanced versions of bagging and IVoting in
21+
CategoryBalancedBaggingLearner and CategoryBalancedIVotingLearner.
22+
* Added online learners based on ROMMA, AROMMA, Ballseptron, Ramp-loss
23+
Passive Aggressive Perceptron, Shifting Perceptron, Forgetron,
24+
Projectron, Randomized Budget Perceptron, and Stoptron.
25+
* Added KernelizableBinaryCategorizerOnlineLearner interface for an online
26+
linear binary categorizer that can also be used with a kernel. Also
27+
provided abstract class AbstractKernelizableBinaryCategorizerOnlineLearner
28+
and AbstractLinearCombinationOnlineLearner for common functionality.
29+
* Moved KernelPerceptron and KernelAdatron to the new
30+
learning.perceptron.kernel package.
31+
* Added KernelUtil utility class for dealing with kernels and kernel
32+
binary categorizers.
33+
* Refactored statistics to remove getMean() from Distribution due to
34+
some distributions not having a meaningful mean and confusion for what
35+
the mean meant in some classes.
36+
* Classes and interfaces interfaces named *Scalar* renamed to *Univariate*
37+
for clarity.
38+
* Added getTestStatistic() method to ConfidenceStatistic interface and
39+
implemented in existing classes.
40+
* Added support for multiple comparisons tests, including Bonferroni,
41+
Holm, Nemenyi, Shaffer, Sidak, and Tukey-Kramer and updated
42+
AnalysisOfVarianceOneWay (ANOVA) and FriedmanConfidence.
43+
* Added multiple-comparisons experiment classes BlockExperimentComparison
44+
and MultipleComparisonExperiment
45+
* Text Core:
46+
* Renamed ProbabilisticLatentSemanticAnalysis.Transform to
47+
ProbabilisticLatentSemanticAnalysis.Result for consistency.
48+
549
Release 3.2.0 (2011-05-19):
650
* Upgraded to mtj-9.9.14 and added the netlib-java-0.9.3 library, which MTJ
751
now depends on.
Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
/*
2+
* File: LogMath.java
3+
* Authors: Justin Basilico
4+
* Company: Sandia National Laboratories
5+
* Project: Cognitive Foundry
6+
*
7+
* Copyright June 13, 2011, Sandia Corporation.
8+
* Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
9+
* license for use of this work by or on behalf of the U.S. Government. Export
10+
* of this program may require a license from the United States Government.
11+
* See CopyrightHistory.txt for complete details.
12+
*
13+
*/
14+
15+
package gov.sandia.cognition.math;
16+
17+
/**
18+
* A utility class for doing math with numbers represented as logarithms. Thus,
19+
* the number x is instead represented as log(x). This can be useful when
20+
* doing computation involving many products, such as with probabilities.
21+
*
22+
* @author Justin Basilico
23+
* @since 3.3.0
24+
*/
25+
public class LogMath
26+
{
27+
28+
/** The natural logarithm of 0 (log(0)), which is negative infinity. */
29+
public static final double LOG_0 = Double.NEGATIVE_INFINITY;
30+
31+
/** The natural logarithm of 1 (log(1)), which is 0. */
32+
public static final double LOG_1 = 0.0;
33+
34+
/** The natural logarithm of 2 (log(2)). */
35+
public static final double LOG_2 = Math.log(2.0);
36+
37+
/** The natural logarithm of 10 (log(10)). */
38+
public static final double LOG_10 = Math.log(10.0);
39+
40+
/**
41+
* Converts a number to its log-domain representation (log(x)). Negative
42+
* values will result in NaN.
43+
*
44+
* @param x
45+
* The number. Should not be negative.
46+
* @return
47+
* The logarithm of x (log(x)).
48+
*/
49+
public static double toLog(
50+
final double x)
51+
{
52+
return Math.log(x);
53+
}
54+
55+
/**
56+
* Converts a number from log-domain representation (x = exp(logX)).
57+
*
58+
* @param logX
59+
* The log-domain representation of the number x (log(x)).
60+
* @return
61+
* The value of x, which is exp(logX) = exp(log(x)).
62+
*/
63+
public static double fromLog(
64+
final double logX)
65+
{
66+
return Math.exp(logX);
67+
}
68+
69+
/**
70+
* Adds two log-domain values. It uses a trick to prevent numerical
71+
* overflow and underflow.
72+
*
73+
* @param logX
74+
* The first log-domain value (log(x)).
75+
* Must be the same basis as logY.
76+
* @param logY
77+
* The second log-domain value (log(y)).
78+
* Must be the same basis as logX.
79+
* @return
80+
* The log of x plus y (log(x + y)).
81+
*/
82+
public static double add(
83+
final double logX,
84+
final double logY)
85+
{
86+
if (logX > logY)
87+
{
88+
return Math.log(1.0 + Math.exp(logY - logX)) + logX;
89+
}
90+
else if (logY > logX)
91+
{
92+
return Math.log(1.0 + Math.exp(logX - logY)) + logY;
93+
}
94+
else
95+
{
96+
// Since x == y, we have log(x + y) = log(x * 2) = log(x) + log(2).
97+
return logX + LOG_2;
98+
}
99+
}
100+
101+
/**
102+
* Subtracts two log-domain values. It uses a trick to prevent numerical
103+
* overflow and underflow.
104+
*
105+
* @param logX
106+
* The first log-domain value (log(x)).
107+
* Must be the same basis as logY.
108+
* @param logY
109+
* The second log-domain value (log(y)).
110+
* Must be the same basis as logX.
111+
* @return
112+
* The log of x minus y (log(x - y)).
113+
*/
114+
public static double subtract(
115+
final double logX,
116+
final double logY)
117+
{
118+
if (logX > logY)
119+
{
120+
return Math.log(1.0 - Math.exp(logY - logX)) + logX;
121+
}
122+
else if (logY > logX)
123+
{
124+
// Since y > x, we will have a log of a negative number, which
125+
// does not exist.
126+
return Double.NaN;
127+
}
128+
else
129+
{
130+
// Since x == y, we have log(x - y) = log(0), which is negative
131+
// infinity.
132+
return LOG_0;
133+
}
134+
}
135+
136+
/**
137+
* Multiplies two log-domain values. It uses the identity:
138+
* log(x * y) = log(x) + log(y)
139+
*
140+
* @param logX
141+
* The first log-domain value (log(x)).
142+
* Must be the same basis as logY.
143+
* @param logY
144+
* The second log-domain value (log(y)).
145+
* Must be the same basis as logX.
146+
* @return
147+
* The log of x divided by y (log(x * y)).
148+
*/
149+
public static double multiply(
150+
final double logX,
151+
final double logY)
152+
{
153+
return logX + logY;
154+
}
155+
156+
/**
157+
* Divides two log-domain values. It uses the identity:
158+
* log(x / y) = log(x) - log(y)
159+
*
160+
* @param logX
161+
* The first log-domain value (log(x)) used in the numerator.
162+
* Must be the same basis as logY.
163+
* @param logY
164+
* The second log-domain value (log(y)) used in the denominator.
165+
* Must be the same basis as logX.
166+
* @return
167+
* The log of x times y (log(x / y)).
168+
*/
169+
public static double divide(
170+
final double logX,
171+
final double logY)
172+
{
173+
return logX - logY;
174+
}
175+
176+
/**
177+
* Takes the inverse of a log-domain value. Using the same identity as
178+
* the division one and that log(1) = 0 to be:
179+
* log(x^-1) = log(1 / x) = log(1) - log(x) = -log(x)
180+
*
181+
* @param logX
182+
* The log-domain value (log(x)) to invert.
183+
* @return
184+
* The log of x^-1 = 1 / x (log(1/x)).
185+
*/
186+
public static double inverse(
187+
final double logX)
188+
{
189+
return -logX;
190+
}
191+
192+
}

0 commit comments

Comments
 (0)