public Distributions(Asset asset, WeightRate weightRate, PDFType pdf, InputModel model) { yearsOfAdditions = asset.yearsOfAdd; yearsOfWithdrawls = asset.yearsOfWith; additions = asset.addPerYear; this.pdf = pdf; withdrawls = asset.withperYear; initialAmount = asset.currAmount; this.model = model; this.asset = asset; percentiles = new List <Percentiles>(9); switch (pdf) { case PDFType.Normal: weightedRates = weightRate.weightedRatesNormal; break; case PDFType.Laplace: weightedRates = weightRate.weightedRatesLaplace; break; case PDFType.T: weightedRates = weightRate.weightedRatesT; break; } Allpercentiles = new List <Percentiles>(weightedRates.Count); GetYearlyBreakdown(); CalculateAverageWithdrawls(); Sort(); ConfidenceIntervals(); ProbabilityOfSuccess(); }
public Ziggurat(PDFType pdfType) { pdf = new PDF(0, 1); switch (pdfType) { case PDFType.Normal: pFunc = pdf.NormalPDF; lowerBound = 0; upperBound = 0x100000000; guess = 3.56; tailBound = 10; break; case PDFType.Laplace: pFunc = pdf.LaplacePDF; lowerBound = 0; upperBound = 5000; guess = 9; tailBound = 10; break; case PDFType.T: pFunc = pdf.TPDF; lowerBound = 0; upperBound = Int16.MaxValue; guess = 4; tailBound = 10; break; } GenerateZigTable(); }
/** Allocate a new PDF Object */ PDFObject createPDFObject(PDFType type) { PDFObject obj = new PDFObject(pdfobjects.Count + 1, type); pdfobjects.Add(obj); return(obj); }
private void MakeWeightRates(PDFType pdf, Task <List <List <double> > >[] tasks) //calculates the total gain % for the whole portfolio for each 10,000 trials { List <double> weightedTrial; double currentTotal = 0; for (int i = 0; i < tasks[0].Result.Count; i++) { weightedTrial = new List <double>(tasks[0].Result[0].Count); for (int j = 0; j < tasks[0].Result[0].Count; j++) { for (int a = 0; a < tasks.Length; a++) { currentTotal += tasks[a].Result[i][j]; //a is the 9 asset classes, i is each trial, and j is the inividual year } weightedTrial.Add(currentTotal); currentTotal = 0; } switch (pdf) { case PDFType.Normal: weightedRatesNormal.Add(weightedTrial); break; case PDFType.Laplace: weightedRatesLaplace.Add(weightedTrial); break; case PDFType.T: weightedRatesT.Add(weightedTrial); break; } } }
/** Retrieve the PDFObject with the given type */ PDFObject getPDFObject(PDFType type) { foreach (PDFObject obj in pdfobjects) { if (obj.PDFType == type) { return(obj); } } return(null); }
private void CalculateRates(PDFType pdf) { Task <List <List <double> > >[] tasks = new Task <List <List <double> > > [9]; tasks[0] = (Task.Run(() => RunCarlo(asset.stocks.lower, pdf))); tasks[1] = (Task.Run(() => RunCarlo(asset.stocks.mid, pdf))); tasks[2] = (Task.Run(() => RunCarlo(asset.stocks.upper, pdf))); tasks[3] = (Task.Run(() => RunCarlo(asset.bonds.lower, pdf))); tasks[4] = (Task.Run(() => RunCarlo(asset.bonds.mid, pdf))); tasks[5] = (Task.Run(() => RunCarlo(asset.bonds.upper, pdf))); tasks[6] = (Task.Run(() => RunCarlo(asset.cash.lower, pdf))); tasks[7] = (Task.Run(() => RunCarlo(asset.cash.mid, pdf))); tasks[8] = (Task.Run(() => RunCarlo(asset.cash.upper, pdf))); Task.WaitAll(tasks); MakeWeightRates(pdf, tasks); }
private List <List <double> > RunCarlo(Breakdown breakdown, PDFType pdf) { Ziggurat zigg; switch (pdf) { case PDFType.Normal: zigg = Startup.normalZigg; break; case PDFType.Laplace: zigg = Startup.laplaceZigg; break; case PDFType.T: zigg = Startup.tZigg; break; default: zigg = Startup.normalZigg; break; } Carlo carlo = Task.Run(() => new Carlo(breakdown.expectedReturn, breakdown.volatility, asset.yearsOfAdd + asset.yearsOfWith, zigg)).Result; List <List <double> > rates = new List <List <double> >(carlo.rates.Count); List <double> rate; for (int i = 0; i < carlo.rates.Count; i++) { rate = new List <double>(carlo.rates[i].Count); for (int j = 0; j < carlo.rates[i].Count; j++) { rate.Add(carlo.rates[i][j] * breakdown.portfolioWeight); } rates.Add(rate); } return(rates); }
public PDFObject(int id, PDFType type) { objectId = id; pdftype = type; }
public void getPDFViewPath(PDFType pdfType) { this.formName = string.Concat(pdfType.ToString(), ".cshtml"); this.viewPath = "~/Views/RT/exportFile/BASIC/" + this.formName; }