/// <summary>Realizes the specified iteration for given stochasti domain mapper and domain prameters.</summary> /// <param name="iteration">The iteration.</param> /// <param name="domainMapper">The domain mapper.</param> /// <param name="parameters">The parameters.</param> /// <returns></returns> /// <exception cref="System.NotImplementedException"></exception> public double Realize(int iteration, IStochasticDomainMapper domainMapper, double[] parameters) { switch (_distributionType) { case RandomVariableDistributionType.Normal: var normalDistribution = new NormalDistribution(_meanValue, _standardDeviation); return(_randomVariable = normalDistribution.NextDouble()); break; case RandomVariableDistributionType.Lognormal: var lognormal = new LognormalDistribution(_meanValue, _standardDeviation * _meanValue); return(_randomVariable = lognormal.NextDouble()); break; default: return(0); throw new NotImplementedException(); break; } }
//--------------------------------------------------------------------- private static double GenerateRandomNum(Distribution dist, double parameter1, double parameter2) { double randomNum = 0.0; if(dist == Distribution.normal) { NormalDistribution randVar = new NormalDistribution(RandomNumberGenerator.Singleton); randVar.Mu = parameter1; // mean randVar.Sigma = parameter2; // std dev randomNum = randVar.NextDouble(); } if(dist == Distribution.lognormal) { LognormalDistribution randVar = new LognormalDistribution(RandomNumberGenerator.Singleton); randVar.Mu = parameter1; // mean randVar.Sigma = parameter2; // std dev randomNum = randVar.NextDouble(); } if(dist == Distribution.gamma) { GammaDistribution randVar = new GammaDistribution(RandomNumberGenerator.Singleton); randVar.Alpha = parameter1; // mean randVar.Theta = parameter2; // std dev randomNum = randVar.NextDouble(); } if(dist == Distribution.Weibull) { WeibullDistribution randVar = new WeibullDistribution(RandomNumberGenerator.Singleton); randVar.Alpha = parameter1; // mean randVar.Lambda = parameter2; // std dev randomNum = randVar.NextDouble(); } return randomNum; }
//--------------------------------------------------------------------- public static double ComputeSize(double meanSize, double sd, SizeType fireSizeType) { if (fireSizeType == SizeType.duration_based) { //-----Edited by BRM----- LognormalDistribution randVar = new LognormalDistribution(RandomNumberGenerator.Singleton); //NormalDistribution randVar = new NormalDistribution(RandomNumberGenerator.Singleton); //GammaDistribution randVar = new GammaDistribution(RandomNumberGenerator.Singleton); //---------- randVar.Mu = meanSize; //randVar.Mu for Lognormal //randVar.Alpha for Gamma randVar.Sigma = sd; //randVar.Sigma for Lognormal //randVar.Theta for Gamma double sizeGenerated = randVar.NextDouble(); if (sizeGenerated < 0) return 0; else return (sizeGenerated); } else if (fireSizeType == SizeType.size_based) { LognormalDistribution randVar = new LognormalDistribution(RandomNumberGenerator.Singleton); //NormalDistribution randVar = new NormalDistribution(RandomNumberGenerator.Singleton); //GammaDistribution randVar = new GammaDistribution(RandomNumberGenerator.Singleton); randVar.Mu = meanSize; //randVar.Mu for Lognormal //randVar.Alpha for Gamma randVar.Sigma = sd; //randVar.Sigma for Lognormal //randVar.Theta for Gamma double sizeGenerated = randVar.NextDouble(); if (sizeGenerated <= 0) return 0; return (sizeGenerated); } return 0.0; }