src/test/java/com/billybyte/commonlibs/testcases/dse/TestCorrelatedRandoms.java
public void testMcVsAnalyticWithModelsWithOptions(){
		// replace vol query
		VolQueryForTest volQuery = 
				(VolQueryForTest)dse.getQueryManager().getQuery(volDiot);
		VolQueryForOptionsTest newVolQuery = 
				new VolQueryForOptionsTest(volQuery.getTestDataMap());
		dse.getQueryManager().registerDioType(volDiot, newVolQuery);
		
//		// create diot map for the each model/security
//		// for this test, pretend the derivative names are the same as the underlying names
		Set<String> derivNames = generateDerivNamesFromUnderlyingNames(underlyingNames);
		Matrix currPriceArrayCopied = getCopiedCurrentValues(derivNames,trials);// this a double[trials][derivNames]
		
		// get a Matrix of trials X shortNames, that holds the values of derivative prices per trial, per shortName
		Matrix resultsPerTrialPerDerivName = getAllTrialValues(derivNames,dse,mcInputsQueryMap,trials);
		// get a Matrix of trials X shortNames that holds the differences of the trial derivative price minus the current 
		//   deriviatve price.
		Matrix derivPriceChangePerTrial = resultsPerTrialPerDerivName.minus(currPriceArrayCopied);
		// now, add the values for each row together, to create a portfolio value per trial
		Matrix ones = new Matrix(underlyingNames.size(),1,1.0);
		double[] portfolioChangesPerTrial = derivPriceChangePerTrial.times(ones).getColumnPackedCopy();

		// the var is the worst n% of these trial sums
		double var = 
				MathStuff.excelPercentile(portfolioChangesPerTrial, .01);
		
		double var2 = getAnalyticVar()/2;
		
		Utils.prt("testMcVsAnalyticWithModelsWithOptions monte carlo var: " + var + "  analytic var: "+var2);
		double diff = Math.abs(var+var2);
		assertTrue(diff<var2*.2);
		
		
	}
/**
	 * This is the main test for monte carlo.
	 * The process of executing a monte carlo run is comprised of several stages:
	 * 1.  Create a dse;
	 * 2.  Get all derivative shortNames;
	 * 3.  Get a Matrix of all initial prices for each security in the portfolio by calling
	 *     getCopiedCurrentValues.  This method calls the dse, and then reorders the price 
	 *     outputs into a Matrix, where the rows are ordered by derivative shortName;
	 * 4.  
	 */
This is the main test for monte carlo.
The process of executing a monte carlo run is comprised of several stages:
1.  Create a dse;
2.  Get all derivative shortNames;
3.  Get a Matrix of all initial prices for each security in the portfolio by calling
getCopiedCurrentValues.  This method calls the dse, and then reorders the price
outputs into a Matrix, where the rows are ordered by derivative shortName;
4.
This is the main test for monte carlo . The process of executing a monte carlo run is comprised of several stages : 1 . Create a dse ; 2 . Get all derivative shortNames ; 3 . Get a Matrix of all initial prices for each security in the portfolio by calling getCopiedCurrentValues . This method calls the dse and then reorders the price outputs into a Matrix where the rows are ordered by derivative shortName ; 4 .
public void testMcVsAnalyticWithModelsWithOptions(){
		VolQueryForTest volQuery = 
				(VolQueryForTest)dse.getQueryManager().getQuery(volDiot);
		VolQueryForOptionsTest newVolQuery = 
				new VolQueryForOptionsTest(volQuery.getTestDataMap());
		dse.getQueryManager().registerDioType(volDiot, newVolQuery);
		Set<String> derivNames = generateDerivNamesFromUnderlyingNames(underlyingNames);
		Matrix currPriceArrayCopied = getCopiedCurrentValues(derivNames,trials);
		Matrix resultsPerTrialPerDerivName = getAllTrialValues(derivNames,dse,mcInputsQueryMap,trials);
		Matrix derivPriceChangePerTrial = resultsPerTrialPerDerivName.minus(currPriceArrayCopied);
		Matrix ones = new Matrix(underlyingNames.size(),1,1.0);
		double[] portfolioChangesPerTrial = derivPriceChangePerTrial.times(ones).getColumnPackedCopy();
		double var = 
				MathStuff.excelPercentile(portfolioChangesPerTrial, .01);
		double var2 = getAnalyticVar()/2;
		Utils.prt("testMcVsAnalyticWithModelsWithOptions monte carlo var: " + var + "  analytic var: "+var2);
		double diff = Math.abs(var+var2);
		assertTrue(diff<var2*.2);
	}
public void testMcVsAnalyticWithModelsWithOptions ( ) { VolQueryForTest volQuery = ( VolQueryForTest ) dse . getQueryManager ( ) . getQuery ( volDiot ) ; VolQueryForOptionsTest newVolQuery = new VolQueryForOptionsTest ( volQuery . getTestDataMap ( ) ) ; dse . getQueryManager ( ) . registerDioType ( volDiot , newVolQuery ) ; Set < String > derivNames = generateDerivNamesFromUnderlyingNames ( underlyingNames ) ; Matrix currPriceArrayCopied = getCopiedCurrentValues ( derivNames , trials ) ; Matrix resultsPerTrialPerDerivName = getAllTrialValues ( derivNames , dse , mcInputsQueryMap , trials ) ; Matrix derivPriceChangePerTrial = resultsPerTrialPerDerivName . minus ( currPriceArrayCopied ) ; Matrix ones = new Matrix ( underlyingNames . size ( ) , 1 , 1.0 ) ; double [ ] portfolioChangesPerTrial = derivPriceChangePerTrial . times ( ones ) . getColumnPackedCopy ( ) ; double var = MathStuff . excelPercentile ( portfolioChangesPerTrial , .01 ) ; double var2 = getAnalyticVar ( ) / 2 ; Utils . prt ( "testMcVsAnalyticWithModelsWithOptions monte carlo var: " + var + "  analytic var: " + var2 ) ; double diff = Math . abs ( var + var2 ) ; assertTrue ( diff < var2 * .2 ) ; }
This is the main test for monte carlo.
This is the main test for monte carlo .
// replace vol query //		// create diot map for the each model/security //		// for this test, pretend the derivative names are the same as the underlying names // this a double[trials][derivNames] // get a Matrix of trials X shortNames, that holds the values of derivative prices per trial, per shortName // get a Matrix of trials X shortNames that holds the differences of the trial derivative price minus the current  //   deriviatve price. // now, add the values for each row together, to create a portfolio value per trial // the var is the worst n% of these trial sums