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

📄 empiricalhistogram.java

📁 金融资产定价,随机过程,MONTE CARLO 模拟 JAVA 程序和文档资料
💻 JAVA
字号:
/* WARANTY NOTICE AND COPYRIGHTThis program is free software; you can redistribute it and/ormodify it under the terms of the GNU General Public Licenseas published by the Free Software Foundation; either version 2of the License, or (at your option) any later version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free SoftwareFoundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.Copyright (C) Michael J. Meyermatmjm@mindspring.comspyqqqdia@yahoo.com*//* * EmpiricalHistogram.java * * Created on March 23, 2002, 5:05 PM */package Examples.Probability;import hep.aida.*;import java.util.Random;import Statistics.*;import Market.*;import TradingStrategies.*;import Triggers.*;import java.lang.Math;import jas.hist.JASHist;import jas.hep.*;import javax.swing.*;/** <p>A data set of N=2000 standard normal random draws is generated. The  *  program then displays two smoothed histograms of sample size N and 50*N of   *  the empirical random variable associated with this data set.<br>  * *  The idea is to see to which extent increased sampling with replacement from  *  the same fixed size data set can improve the approximation to the underlying  *  distribution.</p> * *  <p>Console program, no  *  user interaction. All parameters fixed in source code.</p> * * @author Michael J. Meyer */public class EmpiricalHistogram{    public static void main(String[] args )    throws InterruptedException, java.io.IOException    {         int N=2000;                // size of data set         int nBins=100;             // number of bins                  // construct a raw standard normal sample set         double[] data_set=new double[N];         for(int i=0;i<N;i++)data_set[i]=Statistics.Random.STN();                  // the empirical random variable associatd with this sample set         RandomVariable X=new EmpiricalRandomVariable(data_set);        // a histogram of nSamples samples        String filename="EmpiricalHisto2000.eps";        System.out.println("displaying histogram of 2000 samples");        X.displayHistogram(N,nBins,true,filename,Graphics.Flag.EPS);        Thread.currentThread().sleep(2000);                // a histogram of nSamples samples        filename="EmpiricalHisto100000.eps";        System.out.println("displaying histogram of 100,000 samples");        X.displayHistogram(50*N,nBins,true,filename,Graphics.Flag.EPS);                Thread.currentThread().sleep(2000);                System.out.println("Now writing gri data file.");        filename="EmpiricalHisto2000.dat";        X.basicHistogram(N,nBins,0.005,false).writeGriDataFile(filename);        filename="SmoothedEmpiricalHisto2000.dat";        X.basicHistogram(N,nBins,0.005,true).writeGriDataFile(filename);        filename="EmpiricalHisto100000.dat";        X.basicHistogram(50*N,nBins,0.005,false).writeGriDataFile(filename);        filename="SmoothedEmpiricalHisto100000.dat";        X.basicHistogram(50*N,nBins,0.005,true).writeGriDataFile(filename);        System.out.println("Finished.");                               } // end main     } // end EmpiricalHistogram                          

⌨️ 快捷键说明

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