⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 variable.java

📁 这是一个matlab的java实现。里面有许多内容。请大家慢慢捉摸。
💻 JAVA
字号:
/* Copyright (C) 2003 Univ. of Massachusetts Amherst, Computer Science Dept.   This file is part of "MALLET" (MAchine Learning for LanguagE Toolkit).   http://www.cs.umass.edu/~mccallum/mallet   This software is provided under the terms of the Common Public License,   version 1.0, as published by http://www.opensource.org.  For further   information, see the file `LICENSE' included with this distribution. */package edu.umass.cs.mallet.grmm;import salvo.jesus.graph.VertexImpl;import edu.umass.cs.mallet.base.types.Alphabet;import edu.umass.cs.mallet.base.types.LabelAlphabet;/** *  Class for a discrete random variable in a graphical model. * * Created: Thu Sep 18 09:32:25 2003 * * @author <a href="mailto:casutton@cs.umass.edu">Charles Sutton</a> * @version $Id: Variable.java,v 1.1 2004/07/15 17:53:31 casutton Exp $ */public class Variable extends VertexImpl implements Comparable {	private LabelAlphabet outcomes;	private static int counter = 0;	/**	 * Creates a new variable with the given outcomes.	 */	public Variable (LabelAlphabet outs) {		this.outcomes = outs;		if (outs.size() < 1) {			throw new IllegalArgumentException 				("Attempt to create variable with "+outs.size()+" outcomes.");		}    setIndex();  }	public Variable (int numOutcomes) 	{		if (numOutcomes < 1) {			throw new IllegalArgumentException 				("Attempt to create variable with "+numOutcomes+" outcomes.");		}				outcomes = new LabelAlphabet ();		/* Setup default outcomes */		for (int i = 0; i < numOutcomes; i++) {			outcomes.lookupIndex (new Integer (i));		}    setIndex();  }  private void setIndex()  {    setLabel ("VAR" + (counter++));  }  public int getNumOutcomes () {		return outcomes.size();	}	public Object lookupOutcome (int i) {		return outcomes.lookupObject (i);	}	public LabelAlphabet getLabelAlphabet ()	{		return outcomes;	}  public int compareTo(Object o)  {    /*    Variable var = (Variable) o;    return getLabel().compareTo (var.getLabel());    */    int index = hashCode();    int index2 = ((Variable)o).hashCode();    if (index == index2)      return 0;    else if (index < index2)      return -1;    else return 1;    /**/  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -