new BlackConstantVol(today, sigma_,dayCount)));
new BlackConstantVol(today, sigma_)));
void ReplicationError::compute(Size nTimeSteps, Size nSamples){    QL_REQUIRE(nTimeSteps>0, "the number of steps must be > 0");    // hedging interval    // Time tau = maturity_ / nTimeSteps;    /* Black-Scholes framework: the underlying stock price evolves       lognormally with a fixed known volatility that stays constant       throughout time.    */    Date today = Date::todaysDate();    DayCounter dayCount = Actual365Fixed();    Handle<Quote> stateVariable(                          boost::shared_ptr<Quote>(new SimpleQuote(s0_)));    Handle<YieldTermStructure> riskFreeRate(                          boost::shared_ptr<YieldTermStructure>(                                      new FlatForward(today, r_, dayCount)));    Handle<YieldTermStructure> dividendYield(                          boost::shared_ptr<YieldTermStructure>(                                      new FlatForward(today, 0.0, dayCount)));    Handle<BlackVolTermStructure> volatility(                          boost::shared_ptr<BlackVolTermStructure>(                               new BlackConstantVol(today, sigma_,dayCount)));    boost::shared_ptr<StochasticProcess> diffusion(                         new BlackScholesProcess(stateVariable, dividendYield,                                                 riskFreeRate, volatility));    // Black Scholes equation rules the path generator:    // at each step the log of the stock    // will have drift and sigma^2 variance    PseudoRandom::rsg_type rsg =        PseudoRandom::make_sequence_generator(nTimeSteps, 0);    bool brownianBridge = false;    typedef SingleAsset<PseudoRandom>::path_generator_type generator_type;    boost::shared_ptr<generator_type> myPathGenerator(new        generator_type(diffusion, maturity_, nTimeSteps,                       rsg, brownianBridge));    // The replication strategy's Profit&Loss is computed for each path    // of the stock. The path pricer knows how to price a path using its    // value() method    boost::shared_ptr<PathPricer<Path> > myPathPricer(new        ReplicationPathPricer(payoff_.optionType(), s0_,            payoff_.strike(), r_, maturity_, sigma_));    // a statistics accumulator for the path-dependant Profit&Loss values    Statistics statisticsAccumulator;    // The OneFactorMontecarloModel generates paths using myPathGenerator    // each path is priced using myPathPricer    // prices will be accumulated into statisticsAccumulator    OneFactorMonteCarloOption MCSimulation(myPathGenerator,                                           myPathPricer,                                           statisticsAccumulator,                                           false);    // the model simulates nSamples paths    MCSimulation.addSamples(nSamples);    // the sampleAccumulator method of OneFactorMonteCarloOption_old    // gives access to all the methods of statisticsAccumulator    Real PLMean  = MCSimulation.sampleAccumulator().mean();    Real PLStDev = MCSimulation.sampleAccumulator().standardDeviation();    Real PLSkew  = MCSimulation.sampleAccumulator().skewness();    Real PLKurt  = MCSimulation.sampleAccumulator().kurtosis();    // Derman and Kamal's formula    Real theorStD = QL_SQRT(M_PI/4/nTimeSteps)*vega_*sigma_;    std::cout << nSamples << "\t| "        << nTimeSteps << "\t | "        << DecimalFormatter::toString(PLMean,   3) << " \t| "        << DecimalFormatter::toString(PLStDev,  2) << " \t  | "        << DecimalFormatter::toString(theorStD, 2) << " \t | "        << DecimalFormatter::toString(PLSkew,   2) << " \t| "        << DecimalFormatter::toString(PLKurt,   2) << std::endl;}