29 | *
30 | * @version $Revision: 920852 $ $Date: 2010-03-09 07:53:44 -0500 (Tue, 09 Mar 2010) $
31 | */
32 | public interface TDistribution extends ContinuousDistribution {
33 | /**
34 | * Modify the degrees of freedom.
35 | *
36 | * @param degreesOfFreedom the new degrees of freedom.
37 | * @deprecated as of v2.1
38 | */
39 | @Deprecated
40 | void setDegreesOfFreedom(double degreesOfFreedom);
41 |
42 | /**
43 | * Access the degrees of freedom.
44 | *
45 | * @return the degrees of freedom.
46 | */
47 | double getDegreesOfFreedom();
48 | }
49 |
--------------------------------------------------------------------------------
/src/beast/base/inference/distribution/OneOnX.java:
--------------------------------------------------------------------------------
1 | package beast.base.inference.distribution;
2 |
3 |
4 | import org.apache.commons.math.MathException;
5 | import org.apache.commons.math.distribution.ContinuousDistribution;
6 | import org.apache.commons.math.distribution.Distribution;
7 |
8 | import beast.base.core.Description;
9 |
10 |
11 |
12 | @Description("OneOnX distribution. f(x) = C/x for some normalizing constant C. " +
13 | "If the input x is a multidimensional parameter, each of the dimensions is considered as a " +
14 | "separate independent component.")
15 | public class OneOnX extends ParametricDistribution {
16 |
17 | ContinuousDistribution dist = new OneOnXImpl();
18 |
19 | @Override
20 | public void initAndValidate() {
21 | }
22 |
23 | @Override
24 | public Distribution getDistribution() {
25 | return dist;
26 | }
27 |
28 | class OneOnXImpl implements ContinuousDistribution {
29 |
30 | @Override
31 | public double cumulativeProbability(double x) throws MathException {
32 | throw new MathException("Not implemented yet");
33 | }
34 |
35 | @Override
36 | public double cumulativeProbability(double x0, double x1) throws MathException {
37 | throw new MathException("Not implemented yet");
38 | }
39 |
40 | @Override
41 | public double inverseCumulativeProbability(double p) throws MathException {
42 | throw new MathException("Not implemented yet");
43 | }
44 |
45 | @Override
46 | public double density(double x) {
47 | return 1 / x;
48 | }
49 |
50 | @Override
51 | public double logDensity(double x) {
52 | return -Math.log(x);
53 | }
54 | } // class OneOnXImpl
55 |
56 |
57 | } // class OneOnX
58 |
--------------------------------------------------------------------------------
/test/test/beast/evolution/operator/TestOperator.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package test.beast.evolution.operator;
5 |
6 | import java.util.ArrayList;
7 | import java.util.HashMap;
8 |
9 | import beast.base.inference.Operator;
10 | import beast.base.inference.State;
11 | import beast.base.inference.StateNode;
12 | import static org.junit.jupiter.api.Assertions.assertEquals;
13 |
14 | /**
15 | * @author gereon
16 | *
17 | */
18 | public abstract class TestOperator {
19 |
20 | static public void register(Operator operator, final Object... operands) {
21 | HashMap operandsMap;
22 | operandsMap = new HashMap();
23 | if (operands.length % 2 == 1) {
24 | throw new RuntimeException("Expected even number of arguments, name-value pairs");
25 | }
26 | for (int i = 0; i < operands.length; i += 2) {
27 | if (operands[i] instanceof String) {
28 | final String name = (String) operands[i];
29 | if (operands[i + 1] instanceof StateNode) {
30 | final StateNode node = (StateNode) operands[i + 1];
31 | operandsMap.put(name, node);
32 | } else {
33 | throw new IllegalArgumentException("Expected a StateNode in " + (i + 1) + "th argument ");
34 | }
35 | } else {
36 | throw new IllegalArgumentException("Expected a String in " + i + "th argument ");
37 | }
38 | }
39 | State state = new State();
40 | state.initByName("stateNode", new ArrayList(operandsMap.values()));
41 | state.initialise();
42 | Object[] operandsAndWeight = new Object[operands.length + 2];
43 | for (int i = 0; i < operands.length; ++i) {
44 | operandsAndWeight[i] = operands[i];
45 | }
46 | operandsAndWeight[operands.length] = "weight";
47 | operandsAndWeight[operands.length + 1] = "1";
48 | operator.initByName(operandsAndWeight);
49 | operator.validateInputs();
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | # Dockerfile to build container for unit testing.
2 | #
3 | # To build the image, run the following from this directory:
4 | # docker build -t beast_testing .
5 | #
6 | # To run the tests, use
7 | # docker run beast_testing
8 | #
9 | # To run the tests interactively, use
10 | # docker run --entrypoint /bin/bash -it -p 5900:5900 beast_testing
11 | # This will give you a shell in the container. From this
12 | # shell, run
13 | # vncserver $DISPLAY -geometry 1920x1080; ant -f build-testing.xml
14 | #
15 | # The previous command exposes the VNC session, so while the
16 | # BEAUti test suite is running you can run a VNC viewer and
17 | # connect it to localhost (password: password) to observe
18 | # the graphical output of these tests.
19 |
20 | FROM debian:stable
21 | WORKDIR /beast2
22 |
23 | # Install Apache Ant
24 | RUN apt-get update && apt-get install -y openjdk-21-jdk openjfx ant
25 |
26 | # Install and configure VNC server
27 | RUN apt-get update && apt-get install -y tightvncserver twm
28 | RUN mkdir /root/.vnc
29 | RUN echo password | vncpasswd -f > /root/.vnc/passwd
30 | RUN chmod 600 /root/.vnc/passwd
31 |
32 | # Install BEAGLE
33 | RUN apt-get update && apt-get install -y build-essential autoconf automake libtool pkg-config git
34 | # use latest release v3.1.2, issue #786
35 | RUN cd /root && git clone --branch v3.1.2 --depth=1 https://github.com/beagle-dev/beagle-lib.git
36 | RUN cd /root/beagle-lib && ./autogen.sh && ./configure --prefix=/usr/local && make install
37 | RUN ldconfig
38 |
39 | ADD . ./
40 |
41 | RUN echo "#!/bin/bash\n" \
42 | "export USER=root\n" \
43 | "export DISPLAY=:1\n" \
44 | "vncserver :1 -geometry 1920x1080\n" \
45 | "ant -lib lib -f build-testing.xml \$1\n" > entrypoint.sh
46 | RUN chmod a+x entrypoint.sh
47 |
48 | ENTRYPOINT ["./entrypoint.sh"]
49 |
50 | CMD ["test-all"]
51 |
--------------------------------------------------------------------------------
/src/beast/base/inference/parameter/IntegerParameterList.java:
--------------------------------------------------------------------------------
1 | package beast.base.inference.parameter;
2 |
3 | import java.util.List;
4 |
5 | import beast.base.core.Description;
6 | import beast.base.core.Input;
7 |
8 | /**
9 | * @author Tim Vaughan
10 | */
11 | @Description("State node describing a list of integer-valued parameters.")
12 | public class IntegerParameterList extends GeneralParameterList {
13 |
14 | final public Input lowerBoundInput = new Input<>("lower",
15 | "Lower bound on parameter values.", Integer.MIN_VALUE+1);
16 | final public Input upperBoundInput = new Input<>("upper",
17 | "Upper bound on parameter values.", Integer.MAX_VALUE-1);
18 |
19 | @Override
20 | public void initAndValidate() {
21 | lowerBound = lowerBoundInput.get();
22 | upperBound = upperBoundInput.get();
23 |
24 | super.initAndValidate();
25 | }
26 |
27 | @Override
28 | protected void readStateFromString(String[] boundsString,
29 | List parameterValueStrings,
30 | List keys) {
31 |
32 | lowerBound = Integer.parseInt(boundsString[0]);
33 | upperBound = Integer.parseInt(boundsString[1]);
34 |
35 | pList.clear();
36 |
37 | for (int pidx=0; pidx
10 | */
11 | @Description("State node describing a list of real-valued parameters.")
12 | public class RealParameterList extends GeneralParameterList {
13 |
14 | final public Input lowerBoundInput = new Input<>("lower",
15 | "Lower bound on parameter values.", Double.NEGATIVE_INFINITY);
16 | final public Input upperBoundInput = new Input<>("upper",
17 | "Upper bound on parameter values.", Double.POSITIVE_INFINITY);
18 |
19 | @Override
20 | public void initAndValidate() {
21 | lowerBound = lowerBoundInput.get();
22 | upperBound = upperBoundInput.get();
23 |
24 | super.initAndValidate();
25 | }
26 |
27 | @Override
28 | protected void readStateFromString(String[] boundsString,
29 | List parameterValueStrings,
30 | List keys) {
31 |
32 | lowerBound = Double.parseDouble(boundsString[0]);
33 | upperBound = Double.parseDouble(boundsString[1]);
34 |
35 | pList.clear();
36 |
37 | for (int pidx=0; pidx 1);
31 | assertEquals(11, tree.getNodeCount());
32 | }
33 |
34 | @Test
35 | public void testNewickTree() throws Exception {
36 | Alignment data = BEASTTestCase.getAlignment();
37 | Tree tree = new Tree();
38 | tree.initAndValidate();
39 | assertEquals(true, tree.getNodeCount() == 1);
40 |
41 | ClusterTree tree2 = new ClusterTree();
42 | tree2.initByName(
43 | "initial", tree,
44 | "clusterType", "upgma",
45 | "taxa", data);
46 | assertEquals(true, tree.getNodeCount() > 1);
47 | assertEquals(11, tree.getNodeCount());
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/examples/testDirichlet/testDirichlet.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 | 0.25 0.25 0.25 0.25
9 |
10 |
11 |
12 |
13 |
14 |
15 | 2.0 2.0 2.0 2.0
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/src/beast/base/inference/StateNodeInitialiser.java:
--------------------------------------------------------------------------------
1 | package beast.base.inference;
2 |
3 | import java.util.List;
4 |
5 | /**
6 | * Typically, StateNodes are initialised through their inputs. However, there are initialisation scenarios
7 | * too complex for this approach to work. For example, initialisation may require additional information not
8 | * provided by the inputs, or several dependent beastObjects need to initialise together,
9 | * such as gene trees and a species tree.
10 | *
11 | * StateNodeInitialisers take one or more StateNodes as input and initializes them in initStateNodes().
12 | * getInitialisedStateNodes() reports back which nodes has been initialized, but this is currently only used to
13 | * check for multiple initialiser for the same object.
14 | *
15 | * Like any other isEASTObject, a state initialiser must have an initAndValidate(), which is called once.
16 | * getInitialisedStateNodes(), on the other hand, may be called multiple times as its inputs change while the system
17 | * tries to establish a valid starting state. initAndValidate is executed in order that the XML parser see objects,
18 | * so the inputs are not guaranteed to be initialized at this time. initStateNodes is executed in order of appearance
19 | * in MCMC, so inputs requiring initialization are properly initialized when initStateNodes is called.
20 | *
21 | * @author remco
22 | */
23 | public interface StateNodeInitialiser {
24 |
25 | /**
26 | * Called to set up start state. May be called multiple times. *
27 | */
28 | void initStateNodes();
29 |
30 | /**
31 | * @return list of StateNodes that are initialised
32 | * This information is used to ensure StateNode are not initialised more than once.
33 | * @param stateNodes
34 | */
35 | public void getInitialisedStateNodes(List stateNodes);
36 | }
37 |
--------------------------------------------------------------------------------
/examples/testDirichlet/testDirichletBact.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 | 0.25 0.25 0.25 0.25
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | 2.0 2.0 2.0 2.0
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/examples/testDirichlet/testDirichlet2.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 | 0.25 0.25 0.25 0.25
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | 2.0 2.0 2.0 2.0
16 |
17 |
18 |
19 |
20 |
21 |
22 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/src/beast/base/inference/Runnable.java:
--------------------------------------------------------------------------------
1 | package beast.base.inference;
2 |
3 | import beast.base.core.BEASTObject;
4 | import beast.base.core.Description;
5 |
6 | @Description("Entry point for running a Beast task, for instance an MCMC or other probabilistic " +
7 | "analysis, a simulation, etc.")
8 | public abstract class Runnable extends BEASTObject {
9 |
10 | /** entry point for anything runnable **/
11 | abstract public void run() throws Exception;
12 |
13 |
14 | /** make sure whatever is runnable is valid, but do not run yet **/
15 | public void validate() throws Exception {}
16 |
17 | /**
18 | * Set up information related to the file for (re)storing the State.
19 | * The Runnable implementation is responsible for making its
20 | * State synchronising with the file *
21 | * @param fileName
22 | * @param isRestoreFromFile
23 | */
24 | public void setStateFile(final String fileName, final boolean isRestoreFromFile) {
25 | if (System.getProperty("state.file.name") != null) {
26 | stateFileName = System.getProperty("state.file.name");
27 | } else {
28 | if (System.getProperty("file.name.prefix") != null) {
29 | stateFileName = System.getProperty("file.name.prefix") + fileName;
30 | } else {
31 | stateFileName = fileName;
32 | }
33 | }
34 | restoreFromFile = isRestoreFromFile;
35 | }
36 |
37 | /**
38 | * flag to indicate that the State should be restored from File at the start of the analysis *
39 | */
40 | protected boolean restoreFromFile = false;
41 |
42 | /**
43 | * name of the file store the state in *
44 | */
45 | protected String stateFileName = "state.backup.xml";
46 |
47 | /**
48 | * indicate whether this runnable distinguishes partitions, like MCMC, or not
49 | * **/
50 | public boolean hasPartitions() {return true;}
51 | }
52 |
--------------------------------------------------------------------------------
/src/org/json/JSONException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.json;
18 |
19 | // Note: this class was written without inspecting the non-free org.json sourcecode.
20 |
21 | /**
22 | * Thrown to indicate a problem with the JSON API. Such problems include:
23 | *
24 | *
Attempts to parse or construct malformed documents
25 | *
Use of null as a name
26 | *
Use of numeric types not available to JSON, such as {@link
27 | * Double#isNaN() NaNs} or {@link Double#isInfinite() infinities}.
28 | *
Lookups using an out of range index or nonexistent name
29 | *
Type mismatches on lookups
30 | *
31 | *
32 | *
Although this is a checked exception, it is rarely recoverable. Most
33 | * callers should simply wrap this exception in an unchecked exception and
34 | * rethrow:
35 | *
28 | *
29 | *
30 | * @version $Revision: 920852 $ $Date: 2010-03-09 07:53:44 -0500 (Tue, 09 Mar 2010) $
31 | */
32 | public interface ExponentialDistribution extends ContinuousDistribution /*, HasDensity*/ {
33 | /**
34 | * Modify the mean.
35 | *
36 | * @param mean the new mean.
37 | * @deprecated as of v2.1
38 | */
39 | @Deprecated
40 | void setMean(double mean);
41 |
42 | /**
43 | * Access the mean.
44 | *
45 | * @return the mean.
46 | */
47 | double getMean();
48 |
49 | /**
50 | * Return the probability density for a particular point.
51 | *
52 | * @param x The point at which the density should be computed.
53 | * @return The pdf at point x.
54 | */
55 | double density(Double x);
56 | }
57 |
--------------------------------------------------------------------------------
/release/Linux/jrebin/applauncher:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | if [ -z "$BEAST" ]; then
4 | ## resolve links - $0 may be a link to application
5 | PRG="$0"
6 |
7 | # need this for relative symlinks
8 | while [ -h "$PRG" ] ; do
9 | ls=`ls -ld "$PRG"`
10 | link=`expr "$ls" : '.*-> \(.*\)$'`
11 | if expr "$link" : '/.*' > /dev/null; then
12 | PRG="$link"
13 | else
14 | PRG="`dirname "$PRG"`/$link"
15 | fi
16 | done
17 |
18 | # make it fully qualified
19 | saveddir=`pwd`
20 | BEAST0=`dirname "$PRG"`/..
21 | BEAST=`cd "$BEAST0" && pwd`
22 | cd "$saveddir"
23 | fi
24 |
25 | BEAST_LIB="$BEAST/lib"
26 | export JAVA_HOME="$BEAST/jre"
27 |
28 | if [ -z "$JAVA_HOME" ]; then
29 | JAVA=java
30 | else
31 | JAVA="$JAVA_HOME"/bin/java
32 | fi
33 |
34 |
35 | # use BEAGLE_LIB if the BEAGLE library is not in a standard location
36 | if [ -n "$BEAGLE_LIB" ]; then
37 | if [ -n "$BEAST_EXTRA_LIBS" ]; then
38 | BEAST_EXTRA_LIBS="$BEAST_EXTRA_LIBS:$BEAGLE_LIB"
39 | else
40 | BEAST_EXTRA_LIBS="$BEAGLE_LIB"
41 | fi
42 | fi
43 |
44 | # Explicitly add /usr/local/lib to library search path to ensure
45 | # beast continues to find beagle when installed here. (This is
46 | # necessary due to known problems with certain JREs.)
47 | if [ -z "$LD_LIBRARY_PATH" ]; then
48 | export LD_LIBRARY_PATH=/usr/local/lib
49 | else
50 | export LD_LIBRARY_PATH="$LD_LIBRARY_PATH":/usr/local/lib
51 | fi
52 |
53 | # use BEAST_EXTRA_LIBS variable to load BEAGLE and other libraries from non-default locations
54 | # this assumes that the library path contains all these libraries (or are set through LD_LIBRARY_PATH)
55 | if [ -n "$BEAST_EXTRA_LIBS" ]; then
56 | "$JAVA" -Dlauncher.wait.for.exit=true -Xss256m -Xmx8g -Djava.library.path="$BEAST_EXTRA_LIBS" -Duser.language=en -cp "$BEAST_LIB/launcher.jar" beast.pkgmgmt.launcher.AppLauncherLauncher $*
57 | else
58 | "$JAVA" -Dlauncher.wait.for.exit=true -Xss256m -Xmx8g -Duser.language=en -cp "$BEAST_LIB/launcher.jar" beast.pkgmgmt.launcher.AppLauncherLauncher $*
59 | fi
60 |
--------------------------------------------------------------------------------
/src/beast/base/parser/OutputUtils.java:
--------------------------------------------------------------------------------
1 | package beast.base.parser;
2 |
3 |
4 | import java.text.DecimalFormat;
5 | import java.text.DecimalFormatSymbols;
6 | import java.util.List;
7 | import java.util.Locale;
8 |
9 | /**
10 | * some useful methods
11 | *
12 | * @author Remco Bouckaert
13 | * @author Walter Xie
14 | */
15 | public class OutputUtils {
16 | public final static String SPACE = " ";
17 |
18 | public static String format(String s) {
19 | return format(s, SPACE);
20 | }
21 | public static String format(String s, String space) {
22 | while (s.length() < 8) {
23 | s += " ";
24 | }
25 | return s + space;
26 | }
27 |
28 | public static String format(Double d) {
29 | if (Double.isNaN(d)) {
30 | return "NaN ";
31 | }
32 | if (Math.abs(d) > 1e-4 || d == 0) {
33 | DecimalFormat f = new DecimalFormat("#0.######", new DecimalFormatSymbols(Locale.US));
34 | String str = f.format(d);
35 | if (str.length() > 8) {
36 | str = str.substring(0, 8);
37 | }
38 | while (str.length() < 8) {
39 | str += " ";
40 | }
41 | return str;
42 | } else {
43 | DecimalFormat f = new DecimalFormat("0.##E0", new DecimalFormatSymbols(Locale.US));
44 | String str = f.format(d);
45 | if (str.length() > 8) {
46 | String [] strs = str.split("E");
47 | str = strs[0].substring(0, 8 - strs[1].length() - 1) + "E" + strs[1];
48 | }
49 | while (str.length() < 8) {
50 | str += " ";
51 | }
52 | return str;
53 | }
54 | }
55 |
56 | public static String toString(List> list) {
57 | String s = "";
58 | for (int i = 0; i < list.size(); i++) {
59 | if (i > 0) s += ", ";
60 | Object o = list.get(i);
61 | s += o.toString();
62 | }
63 | return s;
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/release/Linux/jrebin/loganalyser:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | if [ -z "$BEAST" ]; then
4 | ## resolve links - $0 may be a link to application
5 | PRG="$0"
6 |
7 | # need this for relative symlinks
8 | while [ -h "$PRG" ] ; do
9 | ls=`ls -ld "$PRG"`
10 | link=`expr "$ls" : '.*-> \(.*\)$'`
11 | if expr "$link" : '/.*' > /dev/null; then
12 | PRG="$link"
13 | else
14 | PRG="`dirname "$PRG"`/$link"
15 | fi
16 | done
17 |
18 | # make it fully qualified
19 | saveddir=`pwd`
20 | BEAST0=`dirname "$PRG"`/..
21 | BEAST=`cd "$BEAST0" && pwd`
22 | cd "$saveddir"
23 | fi
24 |
25 | BEAST_LIB="$BEAST/lib"
26 | export JAVA_HOME="$BEAST/jre"
27 |
28 | if [ -z "$JAVA_HOME" ]; then
29 | JAVA=java
30 | else
31 | JAVA="$JAVA_HOME"/bin/java
32 | fi
33 |
34 |
35 | # use BEAGLE_LIB if the BEAGLE library is not in a standard location
36 | if [ -n "$BEAGLE_LIB" ]; then
37 | if [ -n "$BEAST_EXTRA_LIBS" ]; then
38 | BEAST_EXTRA_LIBS="$BEAST_EXTRA_LIBS:$BEAGLE_LIB"
39 | else
40 | BEAST_EXTRA_LIBS="$BEAGLE_LIB"
41 | fi
42 | fi
43 |
44 | # Explicitly add /usr/local/lib to library search path to ensure
45 | # beast continues to find beagle when installed here. (This is
46 | # necessary due to known problems with certain JREs.)
47 | if [ -z "$LD_LIBRARY_PATH" ]; then
48 | export LD_LIBRARY_PATH=/usr/local/lib
49 | else
50 | export LD_LIBRARY_PATH="$LD_LIBRARY_PATH":/usr/local/lib
51 | fi
52 |
53 | # use BEAST_EXTRA_LIBS variable to load BEAGLE and other libraries from non-default locations
54 | # this assumes that the library path contains all these libraries (or are set through LD_LIBRARY_PATH)
55 | if [ -n "$BEAST_EXTRA_LIBS" ]; then
56 | "$JAVA" -Dlauncher.wait.for.exit=true -Xss256m -Xmx8g -Djava.library.path="$BEAST_EXTRA_LIBS" -Duser.language=en -cp "$BEAST_LIB/launcher.jar" beast.pkgmgmt.launcher.AppLauncherLauncher beastfx.app.tools.LogAnalyser $*
57 | else
58 | "$JAVA" -Dlauncher.wait.for.exit=true -Xss256m -Xmx8g -Duser.language=en -cp "$BEAST_LIB/launcher.jar" beast.pkgmgmt.launcher.AppLauncherLauncher beastfx.app.tools.LogAnalyser $*
59 | fi
60 |
61 |
62 |
--------------------------------------------------------------------------------
/src/org/apache/commons/math/distribution/HasDensity.java:
--------------------------------------------------------------------------------
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 |
18 | package org.apache.commons.math.distribution;
19 |
20 | import org.apache.commons.math.MathException;
21 |
22 | /**
23 | *
Interface that signals that a distribution can compute the probability density function
24 | * for a particular point.
25 | *
26 | * @param
the type of the point at which density is to be computed, this
27 | * may be for example Double.
28 | *
29 | *
This interface is deprecated. As of version 2.0, the {@link ContinuousDistribution}
30 | * interface will be extended to include a density(double) method.
31 | * @version $Revision: 924362 $ $Date: 2010-03-17 12:45:31 -0400 (Wed, 17 Mar 2010) $
32 | * @deprecated to be removed in math 3.0
33 | */
34 | @Deprecated
35 | public interface HasDensity
{
36 |
37 | /**
38 | * Compute the probability density function.
39 | *
40 | * @param x point for which the probability density is requested
41 | * @return probability density at point x
42 | * @throws MathException if probability density cannot be computed at specifed point
43 | */
44 | double density(P x) throws MathException;
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/src/org/apache/commons/math/distribution/ChiSquaredDistribution.java:
--------------------------------------------------------------------------------
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.distribution;
18 |
19 | /**
20 | * The Chi-Squared Distribution.
21 | *
29 | *
30 | *
31 | * @version $Revision: 920852 $ $Date: 2010-03-09 07:53:44 -0500 (Tue, 09 Mar 2010) $
32 | * @since 1.1
33 | */
34 | public interface CauchyDistribution extends ContinuousDistribution {
35 |
36 | /**
37 | * Access the median.
38 | *
39 | * @return median for this distribution
40 | */
41 | double getMedian();
42 |
43 | /**
44 | * Access the scale parameter.
45 | *
46 | * @return scale parameter for this distribution
47 | */
48 | double getScale();
49 |
50 | /**
51 | * Modify the median.
52 | *
53 | * @param median for this distribution
54 | * @deprecated as of v2.1
55 | */
56 | @Deprecated
57 | void setMedian(double median);
58 |
59 | /**
60 | * Modify the scale parameter.
61 | *
62 | * @param s scale parameter for this distribution
63 | * @deprecated as of v2.1
64 | */
65 | @Deprecated
66 | void setScale(double s);
67 | }
68 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | BEAST 2
2 | =======
3 |
4 | [](https://github.com/CompEvol/beast2/actions?query=workflow%3A%22Core+tests%22)
5 |
6 | BEAST is a cross-platform program for Bayesian inference using MCMC of
7 | molecular sequences. It is entirely oriented towards rooted,
8 | time-measured phylogenies inferred using strict or relaxed molecular
9 | clock models. It can be used as a method of reconstructing phylogenies
10 | but is also a framework for testing evolutionary hypotheses without
11 | conditioning on a single tree topology. BEAST uses MCMC to average
12 | over tree space, so that each tree is weighted proportional to its
13 | posterior probability. We include a simple to use user-interface
14 | program for setting up standard analyses and a suit of programs for
15 | analysing the results.
16 |
17 | NOTE: This directory contains the BEAST 2 source code, and is
18 | therefore of interest primarily to BEAST 2 developers. For binary
19 | releases, user tutorials and other information you should visit the
20 | project website at [beast2.org](https://www.beast2.org).
21 |
22 | Development Rules and Philosophy
23 | --------------------------------
24 |
25 | Aspects relating to BEAST 2 development such as coding style, version
26 | numbering and design philosophy are discussed on the BEAST 2 web page at
27 | [beast2.org/package-development-guide/core-development-rules](https://www.beast2.org/package-development-guide/core-development-rules/).
28 |
29 | License
30 | -------
31 |
32 | BEAST 2 is free software; you can redistribute it and/or modify it
33 | under the terms of the GNU Lesser General Public License as published
34 | by the Free Software Foundation; either version 2.1 of the License, or
35 | (at your option) any later version. A copy of the license is contained
36 | in the file COPYING, located in the root directory of this repository.
37 |
38 | This software is distributed in the hope that it will be useful, but
39 | WITHOUT ANY WARRANTY; without even the implied warranty of
40 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41 | Lesser General Public License contained in the file COPYING for more
42 | details.
43 |
--------------------------------------------------------------------------------
/test/test/beast/evolution/operator/DeltaExchangeOperatorTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package test.beast.evolution.operator;
5 |
6 | import static org.junit.jupiter.api.Assertions.assertEquals;
7 |
8 | import org.junit.jupiter.api.Test;
9 |
10 | import beast.base.inference.State;
11 | import beast.base.inference.operator.DeltaExchangeOperator;
12 | import beast.base.inference.parameter.IntegerParameter;
13 | import beast.base.inference.parameter.RealParameter;
14 |
15 | /**
16 | * @author gereon
17 | *
18 | */
19 | public class DeltaExchangeOperatorTest extends TestOperator {
20 |
21 | @Test
22 | public void testKeepsSum() {
23 | DeltaExchangeOperator operator = new DeltaExchangeOperator();
24 | RealParameter parameter = new RealParameter(new Double[] {1., 1., 1., 1.});
25 | register(operator,
26 | "parameter", parameter);
27 | for (int i=0; i<100; ++i) {
28 | operator.proposal();
29 | }
30 | double i = 0;
31 | for (Double p : parameter.getValues()) {
32 | i += p;
33 | }
34 | assertEquals(i, 4, 0.00001, "The DeltaExchangeOperator should not change the sum of a parameter");
35 | }
36 |
37 | @Test
38 | public void testKeepsWeightedSum() {
39 | RealParameter parameter = new RealParameter(new Double[] {1., 1., 1., 1.});
40 | register(new DeltaExchangeOperator(),
41 | "weightvector", new IntegerParameter(new Integer[] {0, 1, 2, 1}),
42 | "parameter", parameter);
43 | Double[] p = parameter.getValues();
44 | assertEquals(0*p[1]+1*p[1]+2*p[2]+1*p[3], 4, 0.00001,
45 | "The DeltaExchangeOperator should not change the sum of a parameter");
46 | }
47 |
48 | @Test
49 | public void testCanOperate() {
50 | // Test whether a validly initialised operator may make proposals
51 | State state = new State();
52 | RealParameter parameter = new RealParameter(new Double[] { 1., 1., 1., 1. });
53 | state.initByName("stateNode", parameter);
54 | state.initialise();
55 | DeltaExchangeOperator d = new DeltaExchangeOperator();
56 | // An invalid operator should either fail in initByName or make valid
57 | // proposals
58 | try {
59 | d.initByName("parameter", parameter, "weight", 1.0);
60 | } catch (RuntimeException e) {
61 | return;
62 | }
63 | d.proposal();
64 | }
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/src/beast/base/inference/operator/IntRandomWalkOperator.java:
--------------------------------------------------------------------------------
1 | package beast.base.inference.operator;
2 |
3 | import beast.base.core.Description;
4 | import beast.base.core.Input;
5 | import beast.base.core.Input.Validate;
6 | import beast.base.inference.Operator;
7 | import beast.base.inference.parameter.IntegerParameter;
8 | import beast.base.inference.util.InputUtil;
9 | import beast.base.util.Randomizer;
10 |
11 |
12 | @Description("A random walk operator that selects a random dimension of the integer parameter and perturbs the value a " +
13 | "random amount within +/- windowSize.")
14 | public class IntRandomWalkOperator extends Operator {
15 | final public Input windowSizeInput =
16 | new Input<>("windowSize", "the size of the window both up and down", Validate.REQUIRED);
17 | final public Input parameterInput =
18 | new Input<>("parameter", "the parameter to operate a random walk on.", Validate.REQUIRED);
19 |
20 | int windowSize = 1;
21 |
22 | @Override
23 | public void initAndValidate() {
24 | windowSize = windowSizeInput.get();
25 | }
26 |
27 | /**
28 | * override this for proposals,
29 | * returns log of hastingRatio, or Double.NEGATIVE_INFINITY if proposal should not be accepted *
30 | */
31 | @Override
32 | public double proposal() {
33 |
34 | final IntegerParameter param = (IntegerParameter) InputUtil.get(parameterInput,this);
35 |
36 | final int i = Randomizer.nextInt(param.getDimension());
37 | final int value = param.getValue(i);
38 | final int newValue = value + Randomizer.nextInt(2 * windowSize + 1) - windowSize;
39 |
40 | if (newValue < param.getLower() || newValue > param.getUpper()) {
41 | // invalid move, can be rejected immediately
42 | return Double.NEGATIVE_INFINITY;
43 | }
44 | if (newValue == value) {
45 | // this saves calculating the posterior
46 | return Double.NEGATIVE_INFINITY;
47 | }
48 |
49 | param.setValue(i, newValue);
50 |
51 | return 0.0;
52 | }
53 |
54 | @Override
55 | public void optimize(final double logAlpha) {
56 | // nothing to optimise
57 | }
58 |
59 | } // class IntRandomWalkOperator
--------------------------------------------------------------------------------
/src/org/apache/commons/math/distribution/BinomialDistribution.java:
--------------------------------------------------------------------------------
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.distribution;
18 |
19 | /**
20 | * The Binomial Distribution.
21 | *
22 | *
28 | *
29 | *
30 | * @version $Revision: 920852 $ $Date: 2010-03-09 07:53:44 -0500 (Tue, 09 Mar 2010) $
31 | */
32 | public interface FDistribution extends ContinuousDistribution {
33 | /**
34 | * Modify the numerator degrees of freedom.
35 | *
36 | * @param degreesOfFreedom the new numerator degrees of freedom.
37 | * @deprecated as of v2.1
38 | */
39 | @Deprecated
40 | void setNumeratorDegreesOfFreedom(double degreesOfFreedom);
41 |
42 | /**
43 | * Access the numerator degrees of freedom.
44 | *
45 | * @return the numerator degrees of freedom.
46 | */
47 | double getNumeratorDegreesOfFreedom();
48 |
49 | /**
50 | * Modify the denominator degrees of freedom.
51 | *
52 | * @param degreesOfFreedom the new denominator degrees of freedom.
53 | * @deprecated as of v2.1
54 | */
55 | @Deprecated
56 | void setDenominatorDegreesOfFreedom(double degreesOfFreedom);
57 |
58 | /**
59 | * Access the denominator degrees of freedom.
60 | *
61 | * @return the denominator degrees of freedom.
62 | */
63 | double getDenominatorDegreesOfFreedom();
64 | }
65 |
--------------------------------------------------------------------------------
/src/beast/base/evolution/alignment/TreeTipData.java:
--------------------------------------------------------------------------------
1 | package beast.base.evolution.alignment;
2 |
3 |
4 | import java.io.PrintStream;
5 |
6 | import org.w3c.dom.Node;
7 |
8 | import beast.base.core.Description;
9 | import beast.base.core.Input;
10 | import beast.base.core.Input.Validate;
11 | import beast.base.evolution.datatype.DataType;
12 | import beast.base.inference.StateNode;
13 | import beast.base.inference.parameter.Map;
14 |
15 | @Description("Generic class for associating data to tips of a tree, e.g. an Alignment.")
16 | public class TreeTipData extends Map {
17 |
18 | final public Input taxonSetInput =
19 | new Input<>("taxa", "An optional taxon-set used only to sort the sequences into the same order as they appear in the taxon-set.", new TaxonSet(), Validate.OPTIONAL);
20 |
21 | final public Input userDataTypeInput = new Input<>("userDataType", "non-standard, user specified data type, if specified 'dataType' is ignored");
22 |
23 | /** Loggable implementation **/
24 |
25 | @Override
26 | public void init(PrintStream out) {
27 | }
28 |
29 | @Override
30 | public void log(long sample, PrintStream out) {
31 | }
32 |
33 | @Override
34 | public void close(PrintStream out) {
35 | }
36 |
37 |
38 | /** Function implementation **/
39 |
40 | @Override
41 | public int getDimension() {
42 | return 0;
43 | }
44 |
45 | @Override
46 | public double getArrayValue(int dim) {
47 | return 0;
48 | }
49 |
50 | /** Map implementation **/
51 |
52 | @Override
53 | protected Class> mapType() {
54 | return String.class;
55 | }
56 |
57 |
58 | /** StateNode implementation **/
59 |
60 | @Override
61 | public void setEverythingDirty(boolean isDirty) {
62 | }
63 |
64 | @Override
65 | public StateNode copy() {
66 | return null;
67 | }
68 |
69 | @Override
70 | public void assignTo(StateNode other) {
71 | }
72 |
73 | @Override
74 | public void assignFrom(StateNode other) {
75 | }
76 |
77 | @Override
78 | public void assignFromFragile(StateNode other) {
79 | }
80 |
81 | @Override
82 | public void fromXML(Node node) {
83 | }
84 |
85 | @Override
86 | public int scale(double scale) {
87 | return 0;
88 | }
89 |
90 | @Override
91 | protected void store() {
92 | }
93 |
94 | @Override
95 | public void restore() {
96 | }
97 |
98 | }
99 |
--------------------------------------------------------------------------------
/src/beast/base/core/Param.java:
--------------------------------------------------------------------------------
1 | package beast.base.core;
2 |
3 |
4 | import java.lang.annotation.ElementType;
5 | import java.lang.annotation.Retention;
6 | import java.lang.annotation.RetentionPolicy;
7 | import java.lang.annotation.Target;
8 |
9 | /**
10 | * This annotation should be used to provide information about parameters in the constructor of a BEAST object,
11 | * as an alternative way to represent inputs.
12 | *
13 | * Note that any object with a constructor with Param annotations should also have a
14 | * public default constructor without arguments to facilitate cloning models in BEAUti.
15 | *
16 | * Furthermore, every Param annotation should come with a public getter and setter, using
17 | * camelcase for name, with annotation CTor(@Param(name="shape",...) double shape) these
18 | * getter and setter signatures should be in the class:
19 | *
20 | * public double getShape()
21 | * public void setShape(double shape)
22 | *
23 | */
24 | @Target({ElementType.PARAMETER})
25 | @Retention(RetentionPolicy.RUNTIME)
26 | public @interface Param {
27 |
28 | /**
29 | * The name of this parameter, typically the same as the name
30 | * of the constructor argument.
31 | */
32 | String name();
33 |
34 |
35 | /**
36 | * The description of this parameter. Must be specified and contain
37 | * at least 4 words to pass the unit tests.
38 | */
39 | String description();
40 |
41 | /**
42 | * @return the default value as a string. An attempt is made to
43 | * convert the String value defaultValue() to the type associated
44 | * with the constructor argument.
45 | */
46 | String defaultValue() default "";
47 |
48 | /**
49 | * Indicates the value can be omitted, in which case the default
50 | * value is used (an attempt is made to convert the String value
51 | * defaultValue() to the type associated with the constructor
52 | * argument).
53 | *
54 | * Note that if there are different constructors and an argument
55 | * does not appear in the other constructor it has to be marked
56 | * as optional.
57 | */
58 | boolean optional() default false;
59 |
60 | /**
61 | * @return true to indicate this description applies to all its
62 | * inherited classes as well, false otherwise
63 | */
64 | boolean isInheritable() default true;
65 | }
--------------------------------------------------------------------------------
/src/beast/base/parser/PartitionContext.java:
--------------------------------------------------------------------------------
1 | package beast.base.parser;
2 |
3 |
4 | import beast.base.core.BEASTInterface;
5 | import beast.base.evolution.likelihood.GenericTreeLikelihood;
6 |
7 | public class PartitionContext {
8 | public String partition;
9 | public String siteModel;
10 | public String clockModel;
11 | public String tree;
12 |
13 | public PartitionContext() {}
14 |
15 | public PartitionContext(String partition) {
16 | this.partition = partition;
17 | siteModel = partition;
18 | clockModel = partition;
19 | tree = partition;
20 | }
21 |
22 | public PartitionContext(String partition,
23 | String siteModel,
24 | String clockModel,
25 | String tree
26 | ) {
27 | this.partition = partition;
28 | this.siteModel = siteModel;
29 | this.clockModel = clockModel;
30 | this.tree = tree;
31 | }
32 |
33 | public PartitionContext(GenericTreeLikelihood treeLikelihood) {
34 | String id = treeLikelihood.dataInput.get().getID();
35 | id = parsePartition(id);
36 | this.partition = id;
37 | if (treeLikelihood.branchRateModelInput.get() != null) {
38 | id = treeLikelihood.branchRateModelInput.get().getID();
39 | id = parsePartition(id);
40 | }
41 | this.clockModel = id;
42 | id = ((BEASTInterface) treeLikelihood.siteModelInput.get()).getID();
43 | id = parsePartition(id);
44 | this.siteModel = id;
45 | id = treeLikelihood.treeInput.get().getID();
46 | id = parsePartition(id);
47 | this.tree = id;
48 | }
49 |
50 |
51 | static public String parsePartition(String id) {
52 | String partition = id.substring(id.indexOf('.') + 1);
53 | if (partition.indexOf(':') >= 0) {
54 | partition = partition.substring(partition.indexOf(':') + 1);
55 | }
56 | return partition;
57 | }
58 |
59 | @Override
60 | public String toString() {
61 | return partition + "," + siteModel + "," + clockModel + "," + tree;
62 | }
63 |
64 | @Override
65 | public boolean equals(Object obj) {
66 | if (obj == null) {
67 | return false;
68 | }
69 | if (obj instanceof PartitionContext) {
70 | PartitionContext other = (PartitionContext) obj;
71 | return other.partition.equals(partition) &&
72 | other.siteModel.equals(siteModel) &&
73 | other.clockModel.equals(clockModel) &&
74 | other.tree.equals(tree);
75 | }
76 | return false;
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/src/beast/base/core/Description.java:
--------------------------------------------------------------------------------
1 | /*
2 | * File Description.java
3 | *
4 | * Copyright (C) 2010 Remco Bouckaert remco@cs.auckland.ac.nz
5 | *
6 | * This file is part of BEAST2.
7 | * See the NOTICE file distributed with this work for additional
8 | * information regarding copyright ownership and licensing.
9 | *
10 | * BEAST is free software; you can redistribute it and/or modify
11 | * it under the terms of the GNU Lesser General Public License as
12 | * published by the Free Software Foundation; either version 2
13 | * of the License, or (at your option) any later version.
14 | *
15 | * BEAST is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU Lesser General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU Lesser General Public
21 | * License along with BEAST; if not, write to the
22 | * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23 | * Boston, MA 02110-1301 USA
24 | */
25 |
26 | package beast.base.core;
27 |
28 | import java.lang.annotation.ElementType;
29 | import java.lang.annotation.Retention;
30 | import java.lang.annotation.RetentionPolicy;
31 | import java.lang.annotation.Target;
32 |
33 | /**
34 | * This is an annotation that can be used to both
35 | * + document a class at the top of the code and
36 | * + create user documentation for XML Beast files.
37 | *
38 | * The idea is to add @Description("bla bla bla")
39 | * just before class declarations of plug-ins. Applications
40 | * like DocMaker then can pick it up through introspection.
41 | *
42 | * To indicate that the description applies to all derived
43 | * classes, the isInheritable flag is set true by default.
44 | * This does not always apply, for instance when the description
45 | * contains text like "Should not be used directly, but by
46 | * implementations".
47 | */
48 | @Target({ElementType.TYPE})
49 | @Retention(RetentionPolicy.RUNTIME)
50 | public @interface Description {
51 |
52 | /**
53 | * @return the description of the class
54 | */
55 | String value();
56 |
57 | /**
58 | * @return true to indicate this description applies to all its inherited classes as well, false otherwise
59 | */
60 | boolean isInheritable() default true;
61 | }
62 |
--------------------------------------------------------------------------------
/src/org/apache/commons/math/distribution/WeibullDistribution.java:
--------------------------------------------------------------------------------
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 |
18 | package org.apache.commons.math.distribution;
19 |
20 | /**
21 | * Weibull Distribution. This interface defines the two parameter form of the
22 | * distribution as defined by
23 | *
24 | * Weibull Distribution, equations (1) and (2).
25 | *
26 | *
32 | *
33 | *
34 | * @version $Revision: 920852 $ $Date: 2010-03-09 07:53:44 -0500 (Tue, 09 Mar 2010) $
35 | * @since 1.1
36 | */
37 | public interface WeibullDistribution extends ContinuousDistribution {
38 |
39 | /**
40 | * Access the shape parameter.
41 | *
42 | * @return the shape parameter.
43 | */
44 | double getShape();
45 |
46 | /**
47 | * Access the scale parameter.
48 | *
49 | * @return the scale parameter.
50 | */
51 | double getScale();
52 |
53 | /**
54 | * Modify the shape parameter.
55 | *
56 | * @param alpha The new shape parameter value.
57 | * @deprecated as of v2.1
58 | */
59 | @Deprecated
60 | void setShape(double alpha);
61 |
62 | /**
63 | * Modify the scale parameter.
64 | *
65 | * @param beta The new scale parameter value.
66 | * @deprecated as of v2.1
67 | */
68 | @Deprecated
69 | void setScale(double beta);
70 | }
71 |
--------------------------------------------------------------------------------
/src/org/apache/commons/math/distribution/GammaDistribution.java:
--------------------------------------------------------------------------------
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.distribution;
18 |
19 | /**
20 | * The Gamma Distribution.
21 | *
22 | *
30 | *
31 | *
32 | * @version $Revision: 920852 $ $Date: 2010-03-09 07:53:44 -0500 (Tue, 09 Mar 2010) $
33 | */
34 | public interface PoissonDistribution extends IntegerDistribution {
35 |
36 | /**
37 | * Get the mean for the distribution.
38 | *
39 | * @return the mean for the distribution.
40 | */
41 | double getMean();
42 |
43 | /**
44 | * Set the mean for the distribution.
45 | * The parameter value must be positive; otherwise an
46 | * IllegalArgument is thrown.
47 | *
48 | * @param p the mean
49 | * @throws IllegalArgumentException if p ≤ 0
50 | * @deprecated as of v2.1
51 | */
52 | @Deprecated
53 | void setMean(double p);
54 |
55 | /**
56 | * Calculates the Poisson distribution function using a normal approximation.
57 | *
58 | * @param x the upper bound, inclusive
59 | * @return the distribution function value calculated using a normal approximation
60 | * @throws MathException if an error occurs computing the normal approximation
61 | */
62 | double normalApproximateProbability(int x) throws MathException;
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/src/org/apache/commons/math/analysis/solvers/UnivariateRealSolverFactoryImpl.java:
--------------------------------------------------------------------------------
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.analysis.solvers;
18 |
19 | /**
20 | * A concrete {@link UnivariateRealSolverFactory}. This is the default solver factory
21 | * used by commons-math.
22 | *
23 | * The default solver returned by this factory is a {@link BrentSolver}.