Пример #1
0
 // 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 + ")");
 }
Пример #2
0
        public PathGenerator(StochasticProcess process, TimeGrid timeGrid, GSG generator, bool brownianBridge)
        {
            brownianBridge_ = brownianBridge;
            generator_      = generator;
            dimension_      = generator_.dimension();
            timeGrid_       = timeGrid;
            process_        = process as StochasticProcess1D;
            next_           = new Sample <IPath>(new Path(timeGrid_), 1.0);
            temp_           = new InitializedList <double>(dimension_);
            bb_             = new BrownianBridge(timeGrid_);

            if (dimension_ != timeGrid_.size() - 1)
            {
                throw new Exception("sequence generator dimensionality (" + dimension_
                                    + ") != timeSteps (" + (timeGrid_.size() - 1) + ")");
            }
        }
Пример #3
0
        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;
            }
        }