Serving the Quantitative Finance Community

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 8
 
User avatar
Cuchulainn
Topic Author
Posts: 20250
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

User feedback Mr. sitmo's prng

December 15th, 2013, 4:08 pm

Quote double min_ = System.Convert.ToDouble( (*m_nativeClass).min() ); double max_ = System.Convert.ToDouble( (*m_nativeClass).max() );This means your png class needs min() and max()? ??
Last edited by Cuchulainn on December 14th, 2013, 11:00 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Topic Author
Posts: 20250
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

User feedback Mr. sitmo's prng

December 15th, 2013, 6:17 pm

1. I am getting very small rns e-209 etc. when I call C+ from C#. I added Min() and Max() to prng and cal them from C# i.e.(BTW what's the range of values [L,U] of rng()) C++ // new djd //double min() conflict with your result_type!!! double Min() { return std::numeric_limits<double>::min(); } double Max() const { return std::numeric_limits<double>::max(); }C# I // [0,1)double NextDouble(){ double min_ = (*m_nativeClass).Min() ; double max_ = (*m_nativeClass).Max() ; double rng_ = (*m_nativeClass)(); return (rng_ - min_) / (max_ - min_ + 1);}C#, IIpublic class PolarMarsaglia<T> : Rng<T>{ private SitmoWrapper.ManagedWrapper rand; public PolarMarsaglia() { rand = new SitmoWrapper.ManagedWrapper(); } // Seed is from system clock public override T GenerateRn() { dynamic u, v, S; do { u = 2.0 * rand.NextDouble() - 1.0; v = 2.0 * rand.NextDouble() - 1.0; Console.Write(", {0}", rand.NextDouble()); S = u * u + v * v; } while (S >= 1.0); dynamic fac = Math.Sqrt(-2.0 * Math.Log(S) / S); return (T)(u * fac); }}
Last edited by Cuchulainn on December 14th, 2013, 11:00 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Topic Author
Posts: 20250
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

User feedback Mr. sitmo's prng

December 15th, 2013, 8:21 pm

Gotcha! Your C# pseudocode confused me min() --> minAnyways; 1st MC test Pexact = 5.84585NT = 500, NSim = 10^6SitmoBoxMuller = 5.847601.NET BoxMuller = NaNCongrats!Keep tuned!
Last edited by Cuchulainn on December 14th, 2013, 11:00 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Topic Author
Posts: 20250
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

User feedback Mr. sitmo's prng

December 16th, 2013, 1:16 pm

Edited: error
Last edited by Cuchulainn on December 16th, 2013, 11:00 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Topic Author
Posts: 20250
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

User feedback Mr. sitmo's prng

December 16th, 2013, 1:47 pm

QuoteI must say I think the first result is a bit strange? How come different fdm methods don't give different results? I think1. the methods are close in accuracy anyways2. large NT, NSI can take NT = 100 and then see ....
 
User avatar
Cuchulainn
Topic Author
Posts: 20250
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

User feedback Mr. sitmo's prng

December 16th, 2013, 3:51 pm

QuoteOriginally posted by: outrunQuoteOriginally posted by: CuchulainnQuoteI must say I think the first result is a bit strange? How come different fdm methods don't give different results? I think1. the methods are close in accuracy anyways2. large NT, NSI can take NT = 100 and then see ....Ah, ok. And the "methods" in 1. are SDE discretization schemes like Euler, Milstein?Yes, it's the FDM part.
Last edited by Cuchulainn on December 15th, 2013, 11:00 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Topic Author
Posts: 20250
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

User feedback Mr. sitmo's prng

December 16th, 2013, 5:47 pm

Let's take Box Muller. For all NT, NS I get the same anwers for all FDM schemes for Sitmo, but .NET answers are different. So, it does not seem to matter if I use Euler or PC etc.Any ideas why?(ditto for Polar, but the values are less good than Box Muller).