📄 probtable.java
字号:
/*
Jie Bao
2002-04-23
*/
// Condtional Probability Table
public class Probtable
{
public int len;
public int[] type; // of which class?
public double[] Prob;
public Probtable(int k)
{
len = k;
//Index = new int[k];
Prob = new double[k];
type = new int[k];
for (int i = 0 ; i < len ; i++)
{ type[i] =0; Prob[i] = 10e-10; }
}
public void Normalize(double sum)
{
if( sum == 0)
return;
double div = (sum+len*10e-10);
for (int i = 0 ; i < len ; i++ )
{
Prob[i] /= div;
}
}
// normallize by class
// input: numClass: sample number of each class
// limit: the number of classes
public void ClassNormalize(int[] numClass, int limit)
{
for (int j = 0 ; j < len ; j++ )
{
if (numClass[type[j]] != 0)
Prob[j] /= numClass[type[j]];
}
}
public void print()
{
System.out.println("\nlength of table ="+ len);
for (int i = 0 ; i < len ; i++ )
{
System.out.println(i +": type ="+ type[i] + " Prob ="+Prob[i]);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -