// constructors public PathGenerator(StochasticProcess process, double length, int timeSteps, GSG generator, bool brownianBridge) { brownianBridge_ = brownianBridge; generator_ = generator; dimension_ = generator_.dimension(); timeGrid_ = new TimeGrid(length, timeSteps); process_ = process as StochasticProcess1D; next_ = new Sample <IPath>(new Path(timeGrid_), 1.0); temp_ = new InitializedList <double>(dimension_); bb_ = new BrownianBridge(timeGrid_); Utils.QL_REQUIRE(dimension_ == timeSteps, () => "sequence generator dimensionality (" + dimension_ + ") != timeSteps (" + timeSteps + ")"); }
public SobolBrownianGenerator(int factors, int steps, Ordering ordering, ulong seed = 0, SobolRsg.DirectionIntegers directionIntegers = SobolRsg.DirectionIntegers.Jaeckel) { factors_ = factors; steps_ = steps; ordering_ = ordering; generator_ = new InverseCumulativeRsg <SobolRsg, InverseCumulativeNormal>( new SobolRsg(factors * steps, seed, directionIntegers), new InverseCumulativeNormal()); bridge_ = new BrownianBridge(steps); lastStep_ = 0; orderedIndices_ = new InitializedList <List <int> >(factors); bridgedVariates_ = new InitializedList <List <double> >(factors); for (int i = 0; i < factors; i++) { orderedIndices_[i] = new InitializedList <int>(steps); bridgedVariates_[i] = new InitializedList <double>(steps); } switch (ordering_) { case Ordering.Factors: fillByFactor(orderedIndices_, factors_, steps_); break; case Ordering.Steps: fillByStep(orderedIndices_, factors_, steps_); break; case Ordering.Diagonal: fillByDiagonal(orderedIndices_, factors_, steps_); break; default: Utils.QL_FAIL("unknown ordering"); break; } }