java金融与数学
1、commons-math/commons-lang-math
以上两个包是apache下的,前者比后者的功能强大,后者有的功能前都有,后者主要解决平时程序中的一些基本的数学计算,主要是范围判断(*Range),随机数生成(JVMRandom,RandomUtils),分数处理(Fraction),数字转化、大小判断(NumberUtils)等。前者可以处理更复杂的数据分析(org.apache.commons.math.analysis)、复数(org.apache.commons.math.complex)、分布式处理(org.apache.commons.math.distribution)、数据预测估计(org.apache.commons.math.estimation)、分数、遗传学(org.apache.commons.math.genetics)、几何图形(org.apache.commons.math.geometry)、线性代数(org.apache.commons.math.linear)、优化(org.apache.commons.math.optimization)、统计(org.apache.commons.math.stat),传换(org.apache.commons.math.transform)、还有一些常用工具类(org.apache.commons.math.util)。
例子:求两直线的交点,第一条两个端点分别为(0,0)、(1,1),另一条两个端点分别(1,0)、(0,1)。
思路:再条直线的交点,实际就是一个二元一次方程的解。方程的解实际可转化为线性代数中的矩阵。如3x+y=4和x+2y=3这个二元一次方程。转为矩阵为:
现在就可以用上面包org.apache.commons.math.geometry的类RealMatrix计算。
代码:
double[][] coefficientsData = { { 3, 1 }, { 1, 2 } };
RealMatrix coefficients = new RealMatrixImpl(coefficientsData);
double[] constants = { 4, 3 };
double[] solution = coefficients.solve(constants);
System.out.println("它们的交点是:x=" + solution[0] + ";y=" + solution[1]);
总结:如果要用到相应功能的(比如方差variance是在统计stat包里),可查看对应的包中的API和官方例子怎么用。
2、jsjava
这个插件,几乎用js语言重写了apache commons lang中的功能,其实是上面commons-math的js版(jsjava-math.js),主要有
1) jsjava-core.js : include jsjava core classes
2) jsjava-ajax.js : include jsjava ajax classes
3) jsjava-anim.js : include jsjava animation classes
4) jsjava-math.js : include jsjava math classes
5) jsjava-blog.js : include jsjava blog classes
6) jsjava-comp.js : include jsjava components classes
7) jsjava-info.js : include jsjava information classes
相关文档:
今晚聊了一晚天,边看java 边聊天,没有集中精神去看。没搞懂java读取xml 的机制。看了一些书先把他记录一下。采用DOM文档对象模型,第一种方法来解析。听说这种解析会有一些缺点,不过总算调试通了,算是一种进步。
<?xml version="1.0" encoding="utf-8"?>
<item>
<node>aa</node&g ......
=====suppose such a method:
public static void openFile(String fileName, PrintWriter stream) throws FileNotFoundException
{
stream = new PrintWriter(fileName);
}
=====then we want to use it this way:
PrintWriter toFile = null;
try
{
openFile("data.txt", t ......
一:理解多线程
多线程是这样一种机制,它允许在程序中并发执行多个指令流,每个指令流都称为一个线程,彼此间互相独立。
线程又称为轻量级进程,它和进程一样拥有独立的执行控制,由操作系统负责调度,区别在于线程没有独立的存储空间,而是和所属进程中的其它线程共享一个存储空间,这使得线程间的通信远较进程简单。
......
在Firefox 3.6中,当焦点在flash或者java applet对象上时,会出现一个环绕对象的虚线框,当将flash与java applet对象的大小设成100%时,点击对象后页面会出现滚动条,影响显示效果,解决的方法是使用如下的css定义:
:focus {
outline: 0;
}
这样在各个不同的浏览器中显示的效果都能保持一致。 ......
KeywordFilter.java:
import java.io.InputStream;
import java.util.Enumeration;
import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class KeywordFilter
{
private static Pattern pattern = null;
private static KeywordFilter filter = new KeywordF ......