コード例 #1
0
        /// <summary>
        /// Manage the simulation of the variance gamma process
        /// </summary>
        /// <param name="Dates">Simulation dates</param>
        /// <param name="Noise">Gaussian noise for a single path</param>
        /// <param name="OutDynamic">Single path process realization</param>
        public void Simulate(double[] Dates, IReadOnlyMatrixSlice Noise, IMatrixSlice OutDynamic)
        {
            int    steps = OutDynamic.R;
            double GammaNoise, dt;

            OutDynamic[0, 0] = this.s0.fV();
            for (int i = 1; i < steps; i++)
            {
                dt               = Dates[i] - Dates[i - 1];
                this.gamma       = new Fairmat.Statistics.Gamma(dt / this.nu.fV(), 1.0 / this.nu.fV());
                GammaNoise       = this.gamma.Draw(Engine.Generator);
                OutDynamic[i, 0] = OutDynamic[i - 1, 0] * Math.Exp(this.drift * dt +
                                                                   this.theta.fV() * GammaNoise + this.sigma.fV() * Math.Sqrt(GammaNoise) * Noise[i - 1, 0]);
            }
        }
コード例 #2
0
ファイル: VarianceGamma.cs プロジェクト: fairmat/EquityModels
 /// <summary>
 /// Manage the simulation of the variance gamma process
 /// </summary>
 /// <param name="Dates">Simulation dates</param>
 /// <param name="Noise">Gaussian noise for a single path</param>
 /// <param name="OutDynamic">Single path process realization</param>
 public void Simulate(double[] Dates, IReadOnlyMatrixSlice Noise, IMatrixSlice OutDynamic)
 {
     int steps = OutDynamic.R;
     double GammaNoise, dt;
     OutDynamic[0, 0] = this.s0.fV();
     for (int i = 1; i < steps; i++)
     {
         dt = Dates[i] - Dates[i - 1];
         this.gamma = new Fairmat.Statistics.Gamma(dt / this.nu.fV(), 1.0 / this.nu.fV());
         GammaNoise = this.gamma.Draw(Engine.Generator);
         OutDynamic[i, 0] = OutDynamic[i - 1, 0] * Math.Exp(this.drift * dt +
             this.theta.fV() * GammaNoise + this.sigma.fV() * Math.Sqrt(GammaNoise) * Noise[i - 1, 0]);
     }
 }