poissonconstant.java
来自「一个自然语言处理的Java开源工具包。LingPipe目前已有很丰富的功能」· Java 代码 · 共 83 行
JAVA
83 行
package com.aliasi.stats;import com.aliasi.util.AbstractExternalizable;import java.io.IOException;import java.io.ObjectInput;import java.io.ObjectOutput;/** * A <code>PoissonConstant</code> implements a Poisson * distribution with a fixed mean. Constant distributions may be * compiled to an object output; the distribution read back in will * also be a constant Poisson distribution. * * @author Bob Carpenter * @version 2.0 * @since LingPipe2.0 */public class PoissonConstant extends PoissonDistribution { private final double mMean; /** * Construct a constant Poisson distribution with the specified * mean. * * @param mean Mean of distribution. * @throws IllegalArgumentException If mean is not a finite * positive number. */ public PoissonConstant(double mean) { if (mean <= 0.0) { String msg = "Mean must be finite and strictly > 0." + " Found mean=" + mean; throw new IllegalArgumentException(msg); } mMean = mean; } /** * Compiles an instance of this constant Poisson distribution to * the specified object output. The corresponding object read in * will be an instance of this class, * <code>PoissonConstant</code>, with the same mean * as this distribution. * * @param objOut Object output to which this distribution is * compiled. * @throws IOException If there is an I/O exception writing. */ public void compileTo(ObjectOutput objOut) throws IOException { objOut.writeObject(new Externalizer(this)); } /** * Returns the mean of this distribution, which is fixed at * construction time. * * @return Mean of this Poisson distribution. */ public double mean() { return mMean; } private static class Externalizer extends AbstractExternalizable { private static final long serialVersionUID = -2824074866517957016L; final PoissonConstant mDistro; public Externalizer() { mDistro = null; } Externalizer(PoissonConstant distro) { mDistro = distro; } public void writeExternal(ObjectOutput objOut) throws IOException { objOut.writeDouble(mDistro.mean()); } protected Object read(ObjectInput objIn) throws IOException { return new PoissonConstant(objIn.readDouble()); } }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?