Changeset 178
- Timestamp:
- 05/22/08 17:13:46 (6 months ago)
- Files:
-
- trunk/QLNet/QLNet.vsmdi (modified) (1 diff)
- trunk/QLNet/QLNet/Math/Distributions/NormalDistribution.cs (modified) (5 diffs)
- trunk/QLNet/QLNet/Math/Distributions/poissondistribution.cs (added)
- trunk/QLNet/QLNet/Math/factorial.cs (modified) (1 diff)
- trunk/QLNet/QLNet/Math/randomnumbers/inversecumulativerng.cs (added)
- trunk/QLNet/QLNet/Math/randomnumbers/inversecumulativersg.cs (added)
- trunk/QLNet/QLNet/Math/randomnumbers/mt19937uniformrng.cs (modified) (1 diff)
- trunk/QLNet/QLNet/Math/randomnumbers/randomsequencegenerator.cs (modified) (2 diffs)
- trunk/QLNet/QLNet/Math/randomnumbers/rngtraits.cs (modified) (3 diffs)
- trunk/QLNet/QLNet/Math/randomnumbers/seedgenerator.cs (modified) (2 diffs)
- trunk/QLNet/QLNet/QLNet.csproj (modified) (2 diffs)
- trunk/QLNet/QLNet/Types.cs (modified) (1 diff)
- trunk/QLNet/Test2008/T_RNGTraits.cs (added)
- trunk/QLNet/Test2008/Test2008.csproj (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/QLNet/QLNet.vsmdi
r176 r178 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 2 <TestLists xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2006"> 3 <TestList name="RNG traits tests" id="028c0346-c4a8-421f-910f-5e69a6d34948" parentListId="8c43106b-9dc1-4907-a29f-aa66a61bf5b6"> 4 <TestLinks> 5 <TestLink id="2c8ad1d8-9257-8f7b-28d9-c01e5092e45f" name="testDefaultPoisson" storage="test2008\bin\debug\test2008.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, PublicKeyToken=b03f5f7f11d50a3a" /> 6 <TestLink id="6cc3a76a-075f-a376-0049-5776a2109de9" name="testGaussian" storage="test2008\bin\debug\test2008.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, PublicKeyToken=b03f5f7f11d50a3a" /> 7 <TestLink id="8d280fda-51c2-ef63-d7d7-4e5c3b00a6de" name="testCustomPoisson" storage="test2008\bin\debug\test2008.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, PublicKeyToken=b03f5f7f11d50a3a" /> 8 </TestLinks> 9 </TestList> 3 10 <TestList name="Swap" id="1fb9da58-c37b-40da-9772-c8899ed4f8c6" parentListId="8c43106b-9dc1-4907-a29f-aa66a61bf5b6"> 4 11 <TestLinks> trunk/QLNet/QLNet/Math/Distributions/NormalDistribution.cs
r106 r178 33 33 classes. 34 34 */ 35 public class NormalDistribution {35 public class NormalDistribution : IValue { 36 36 private double average_, sigma_, normalizationFactor_, denominator_, derNormalizationFactor_; 37 37 … … 73 73 Dover Publications, New York (1972) 74 74 */ 75 public class CumulativeNormalDistribution {75 public class CumulativeNormalDistribution : IValue { 76 76 private double average_, sigma_; 77 77 private NormalDistribution gaussian_ = new NormalDistribution(); … … 359 359 360 360 */ 361 public class InverseCumulativeNormal {361 public class InverseCumulativeNormal : IValue { 362 362 double average_, sigma_; 363 363 … … 393 393 394 394 395 //public InverseCumulativeNormal(double average = 0.0, double sigma = 1.0);395 public InverseCumulativeNormal() : this(0.0, 1.0) { } 396 396 public InverseCumulativeNormal(double average, double sigma) { 397 397 average_ = average; … … 465 465 as QuantLib::InverseCumulativeNormal 466 466 */ 467 public class MoroInverseCumulativeNormal {467 public class MoroInverseCumulativeNormal : IValue { 468 468 private double average_, sigma_; 469 469 trunk/QLNet/QLNet/Math/factorial.cs
r118 r178 28 28 */ 29 29 public static class Factorial { 30 public static double get( int i) {30 public static double get(uint i) { 31 31 if (i<=tabulated) { 32 32 return firstFactorials[i]; trunk/QLNet/QLNet/Math/randomnumbers/mt19937uniformrng.cs
r170 r178 109 109 private void seedInitialization(ulong seed) { 110 110 /* initializes mt with a seed */ 111 ulong s = (seed != 0 ? seed : SeedGenerator. get());111 ulong s = (seed != 0 ? seed : SeedGenerator.instance().get()); 112 112 mt[0]= s & 0xffffffffUL; 113 113 for (mti=1; mti<N; mti++) { trunk/QLNet/QLNet/Math/randomnumbers/randomsequencegenerator.cs
r170 r178 23 23 24 24 namespace QLNet { 25 public interface IRNG { 26 int dimension(); 27 Sample<List<double>> nextSequence(); 28 } 29 25 30 /*! Random sequence generator based on a pseudo-random number generator RNG. 26 31 … … 32 37 \warning do not use with low-discrepancy sequence generator. 33 38 */ 34 public class RandomSequenceGenerator<RNG> where RNG : IRNGTraits, new() {39 public class RandomSequenceGenerator<RNG> : IRNG where RNG : IRNGTraits, new() { 35 40 // typedef Sample<std::vector<Real> > sample_type; 36 41 private int dimensionality_; trunk/QLNet/QLNet/Math/randomnumbers/rngtraits.cs
r170 r178 31 31 32 32 // random number traits 33 public class GenericPseudoRandom<URNG, IC> where URNG : IRNGTraits, new() { 33 public class GenericPseudoRandom<URNG, IC> 34 where URNG : IRNGTraits, new() 35 where IC : IValue, new() { 34 36 // data 35 static IC icInstance;37 public static IC icInstance; 36 38 37 39 //// typedefs … … 45 47 46 48 // factory 47 //static InverseCumulativeRsg<RandomSequenceGenerator<URNG>,IC> make_sequence_generator(int dimension, Int64 seed) { 48 // RandomSequenceGenerator<URNG> g(dimension, seed); 49 // return (icInstance ? rsg_type(g, *icInstance) : rsg_type(g)); 50 //} 49 public static InverseCumulativeRsg<RandomSequenceGenerator<URNG>,IC> make_sequence_generator(int dimension, ulong seed) { 50 RandomSequenceGenerator<URNG> g = new RandomSequenceGenerator<URNG>(dimension, seed); 51 return (icInstance != null ? new InverseCumulativeRsg<RandomSequenceGenerator<URNG>, IC>(g, icInstance) 52 : new InverseCumulativeRsg<RandomSequenceGenerator<URNG>, IC>(g)); 53 } 51 54 } 52 55 … … 55 58 // typedef GenericPseudoRandom<MersenneTwisterUniformRng, InverseCumulativeNormal> PseudoRandom; 56 59 public class PseudoRandom : GenericPseudoRandom<MersenneTwisterUniformRng, InverseCumulativeNormal> { } 60 61 //! traits for Poisson-distributed pseudo-random number generation 62 /*! \test sequence generators are generated and tested by comparing 63 samples against known good values. 64 */ 65 // typedef GenericPseudoRandom<MersenneTwisterUniformRng, InverseCumulativePoisson> PoissonPseudoRandom; 66 public class PoissonPseudoRandom : GenericPseudoRandom<MersenneTwisterUniformRng, InverseCumulativePoisson> { } 57 67 } trunk/QLNet/QLNet/Math/randomnumbers/seedgenerator.cs
r168 r178 28 28 private static MersenneTwisterUniformRng rng_; 29 29 30 private static readonly SeedGenerator instance_ = new SeedGenerator(); 30 31 private SeedGenerator() { 31 32 rng_ = new MersenneTwisterUniformRng(42UL); … … 33 34 } 34 35 35 public staticulong get() {36 public ulong get() { 36 37 return rng_.nextInt32(); 37 38 } 39 40 public static SeedGenerator instance() { return instance_; } 38 41 39 42 private void initialize() { trunk/QLNet/QLNet/QLNet.csproj
r175 r178 139 139 <Compile Include="Math\Distributions\GammaDistribution.cs" /> 140 140 <Compile Include="Math\Distributions\NormalDistribution.cs" /> 141 <Compile Include="Math\Distributions\poissondistribution.cs" /> 141 142 <Compile Include="Math\factorial.cs" /> 142 143 <Compile Include="Math\integrals\Integral.cs" /> … … 161 162 <Compile Include="Math\Optimization\Simplex.cs" /> 162 163 <Compile Include="Math\Optimization\SteepestDescent.cs" /> 164 <Compile Include="Math\randomnumbers\inversecumulativerng.cs" /> 165 <Compile Include="Math\randomnumbers\inversecumulativersg.cs" /> 163 166 <Compile Include="Math\randomnumbers\mt19937uniformrng.cs" /> 164 167 <Compile Include="Math\randomnumbers\primitivepolynomials.cs" /> trunk/QLNet/QLNet/Types.cs
r173 r178 21 21 22 22 namespace QLNet { 23 // interface for all value methods 24 public interface IValue { 25 double value(double v); 26 } 27 23 28 public struct Const { 24 29 public const double QL_Epsilon = 2.2204460492503131e-016; trunk/QLNet/Test2008/Test2008.csproj
r175 r178 8 8 <OutputType>Library</OutputType> 9 9 <AppDesignerFolder>Properties</AppDesignerFolder> 10 <RootNamespace>Test 2008</RootNamespace>10 <RootNamespace>TestSuite</RootNamespace> 11 11 <AssemblyName>Test2008</AssemblyName> 12 12 <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> … … 56 56 <Compile Include="T_Operators.cs" /> 57 57 <Compile Include="T_RiskStats.cs" /> 58 <Compile Include="T_RNGTraits.cs" /> 58 59 <Compile Include="T_Rounding.cs" /> 59 60 <Compile Include="T_SampledCurve.cs" />