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 ......
在JAVA文件中获取该项目的相对路径
1.基本概念的理解
绝对路径:绝对路径就是你的主页上的文件或目录在硬盘上真正的路径,(URL和物理路径)例如:
C:\xyz\test.txt 代表了test.txt文件的绝对路径。http://www.sun.com/index.htm也代表了一个
URL绝对路径。
相对路径:相对与某个基准目录的路径。包含Web的 ......
首先,建3个接口
FTPOperate.java:
public interface FTPOperate
{
public void execute(FTPBean entity);
}
FTPProxy.java:
public interface FTPProxy
{
public void connection();
public abstract void upload();
public abstract void download();
public void setEntity(FTPBe ......
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 ......