当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript simulation.Simulation类代码示例

本文整理汇总了TypeScript中src/service/simulation.Simulation的典型用法代码示例。如果您正苦于以下问题:TypeScript Simulation类的具体用法?TypeScript Simulation怎么用?TypeScript Simulation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Simulation类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: it

 it('should be the present value of the future value with the cash return rate when 100% cash', () => {
   let cashAccount = new Account(1, 'Cash account', '401k', 10000, 1200, 100, 0, 0);
   let futureValueWithContribution = Simulation.futureValueWithContribution(cashAccount.balance, 10, Simulation.CASH_RETURN, cashAccount.contribution);
   let presentValue = Simulation.presentValue(futureValueWithContribution, 10, Simulation.INTEREST);
   let retirementBalance = Simulation.retirementBalance(cashAccount, 10);
   expect(retirementBalance).toBeCloseTo(presentValue, 2);
 });
开发者ID:jasoncarreira,项目名称:choices,代码行数:7,代码来源:simulation.spec.ts

示例2: describe

describe('The chance of success', () => {
  let stockAccount = new Account(1, 'Stock account', '401k', 250000, 8000, 0, 0, 100);
  let retirementBalance = Simulation.retirementBalance(stockAccount, 10);
  let availableRetirementIncome = 0.04 * retirementBalance;
  let currentSalary = (availableRetirementIncome + 21387)/ 0.80; // social security
  let user = new User(1, "First", "Last", 55, 65, currentSalary, [stockAccount]);
  let input = new CalculationInput(user, 0.80);
  let simulationResult:SimulationResult = Simulation.simulateChanceOfSuccess(input);
  it('should not be null or undefined', () => {
    expect(simulationResult).not.toBeNull();
    expect(simulationResult).not.toBeUndefined();
  });

  it('should be 0.5 for the mean', () => {
    expect(simulationResult.chanceOfSuccess).toBeCloseTo(0.5,2);
  });
  let input2 = new CalculationInput(user, 0.90);
  let simulationResult2 = Simulation.simulateChanceOfSuccess(input2);

  it('should be less than 0.5 for a higher required income', () => {
    expect(simulationResult2.chanceOfSuccess).toBeLessThan(0.5);
  });
  let input3 = new CalculationInput(user, 0.70);
  let simulationResult3 = Simulation.simulateChanceOfSuccess(input3);

  it('should be more than 0.5 for a lower required income', () => {
    expect(simulationResult3.chanceOfSuccess).toBeGreaterThan(0.5);
  });
});
开发者ID:jasoncarreira,项目名称:choices,代码行数:29,代码来源:simulation.spec.ts


注:本文中的src/service/simulation.Simulation类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。