<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Finance on Chase the Devil</title>
		<link>https://31416.org/tags/finance/</link>
		<description>Recent content in Finance on Chase the Devil</description>
		<generator>Hugo</generator>
		<language>en-us</language>
		
		
		
		
			<lastBuildDate>Tue, 30 Apr 2013 17:05:00 +0000</lastBuildDate>
		
			<atom:link href="https://31416.org/tags/finance/index.xml" rel="self" type="application/rss+xml" />
			<item>
				<title>Upper Bounds in American Monte-Carlo</title>
				<link>https://31416.org/post/upper-bounds-in-american-monte-carlo/</link>
				<pubDate>Tue, 30 Apr 2013 17:05:00 +0000</pubDate>
				<guid>https://31416.org/post/upper-bounds-in-american-monte-carlo/</guid>
				<description>&lt;a href=&#34;http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.159.2367&amp;amp;rep=rep1&amp;amp;type=pdf&#34;&gt;Glasserman and Yu&lt;/a&gt; (GY) give a relatively simple algorithm to compute lower and upper bounds of a the price of a Bermudan Option through Monte-Carlo.&lt;br /&gt;&lt;br /&gt;I always thought it was very computer intensive to produce an upper bound, and that the standard &lt;a href=&#34;http://escholarship.org/uc/item/43n1k4jb.pdf&#34;&gt;Longstaff Schwartz algorithm&lt;/a&gt; was quite precise already. GY algorithm is not much slower than the Longstaff-Schwartz algorithm, but what&#39;s a bit tricky is the choice of basis functions: they have to be Martingales. This is the detail I overlooked at first and I, then, could not understand why my results were so bad. I looked for a coding mistake for several hours before I figured out that my basis functions were not Martingales. Still it is possible to find good Martingales for the simple Bermudan Put option case and GY actually propose some &lt;a href=&#34;http://arxiv.org/pdf/math.PR/0503556&#34;&gt;in another paper&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Here are some preliminary results where I compare the random number generator influence and the different methods. I include results for GY using In-the-money paths only for the regression (-In suffix) or all (no suffix). &lt;br /&gt;&lt;br /&gt;&lt;div class=&#34;separator&#34; style=&#34;clear: both; text-align: center;&#34;&gt;&lt;/div&gt;&lt;table align=&#34;center&#34; cellpadding=&#34;0&#34; cellspacing=&#34;0&#34; class=&#34;tr-caption-container&#34; style=&#34;margin-left: auto; margin-right: auto; text-align: center;&#34;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&#34;text-align: center;&#34;&gt;&lt;a href=&#34;http://2.bp.blogspot.com/-c7Jhn_s05Ak/UYACCpfoRjI/AAAAAAAAGXQ/LoQscl4b4yM/s1600/gy_train16k_sim_value.png&#34; imageanchor=&#34;1&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;&lt;img border=&#34;0&#34; height=&#34;238&#34; src=&#34;http://2.bp.blogspot.com/-c7Jhn_s05Ak/UYACCpfoRjI/AAAAAAAAGXQ/LoQscl4b4yM/s400/gy_train16k_sim_value.png&#34; width=&#34;400&#34; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&#34;tr-caption&#34; style=&#34;text-align: center;&#34;&gt;value using 16k training path and Sobol - GY-Low-In is very close to LS.&lt;/td&gt;&lt;td class=&#34;tr-caption&#34; style=&#34;text-align: center;&#34;&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class=&#34;separator&#34; style=&#34;clear: both; text-align: center;&#34;&gt;&lt;/div&gt;&lt;div class=&#34;separator&#34; style=&#34;clear: both; text-align: center;&#34;&gt;&lt;/div&gt;&lt;table align=&#34;center&#34; cellpadding=&#34;0&#34; cellspacing=&#34;0&#34; class=&#34;tr-caption-container&#34; style=&#34;margin-left: auto; margin-right: auto; text-align: center;&#34;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&#34;text-align: center;&#34;&gt;&lt;a href=&#34;http://4.bp.blogspot.com/-Jx0NPC1QvAs/UYACisXbFiI/AAAAAAAAGXY/mvsHmNhENcE/s1600/gy_tr16k_sim.png&#34; imageanchor=&#34;1&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;&lt;img border=&#34;0&#34; height=&#34;300&#34; src=&#34;http://4.bp.blogspot.com/-Jx0NPC1QvAs/UYACisXbFiI/AAAAAAAAGXY/mvsHmNhENcE/s640/gy_tr16k_sim.png&#34; width=&#34;640&#34; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&#34;tr-caption&#34; style=&#34;text-align: center;&#34;&gt;error using 16k training path - a high number of simulations not that useful&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;table align=&#34;center&#34; cellpadding=&#34;0&#34; cellspacing=&#34;0&#34; class=&#34;tr-caption-container&#34; style=&#34;margin-left: auto; margin-right: auto; text-align: center;&#34;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&#34;text-align: center;&#34;&gt;&lt;a href=&#34;http://2.bp.blogspot.com/-w6Mp3BDNp-w/UYADEhUQx4I/AAAAAAAAGXg/ESRJyLUybNk/s1600/gy_sim1m_training.png&#34; imageanchor=&#34;1&#34; style=&#34;margin-left: auto; margin-right: auto;&#34;&gt;&lt;img border=&#34;0&#34; height=&#34;282&#34; src=&#34;http://2.bp.blogspot.com/-w6Mp3BDNp-w/UYADEhUQx4I/AAAAAAAAGXg/ESRJyLUybNk/s640/gy_sim1m_training.png&#34; width=&#34;640&#34; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&#34;tr-caption&#34; style=&#34;text-align: center;&#34;&gt;error using 1m simulation paths - GY basis functions require less training than LS&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;One can see the the upper bound is not that precise compared to the lower bound estimate, and that using only in the money paths makes a big difference. GY regression is good with only 1k paths, LS requires 10x more.&lt;br /&gt;&lt;br /&gt;Surprisingly, I noticed that the Brownian bridge variance reduction applied to Sobol was&amp;nbsp; increasing the GY low estimate, so as to make it sometimes slightly higher than Longstaff-Schwartz price.</description>
			</item>
			<item>
				<title>Quasi Monte-Carlo &amp; Longstaff-Schwartz American Option price</title>
				<link>https://31416.org/post/quasi-monte-carlo--longstaff-schwartz-american-option-price/</link>
				<pubDate>Mon, 22 Apr 2013 18:00:00 +0000</pubDate>
				<guid>https://31416.org/post/quasi-monte-carlo--longstaff-schwartz-american-option-price/</guid>
				<description>In the book &lt;i&gt;&lt;a href=&#34;http://books.google.fr/books?id=e9GWUsQkPNMC&amp;amp;lpg=PA461&amp;amp;vq=longstaff&amp;amp;hl=fr&amp;amp;pg=PA459#v=snippet&amp;amp;q=longstaff&amp;amp;f=false&#34;&gt;Monte Carlo Methods in Financial Engineering&lt;/a&gt;&lt;/i&gt;, Glasserman explains that if one reuses the paths used in the optimization procedure for the parameters of the exercise boundary (in this case the result of the regression in Longstaff-Schwartz method) to compute the Monte-Carlo mean value, we will introduce a bias: the estimate will be biased high because it will include knowledge about future paths.&lt;br /&gt;&lt;br /&gt;However Longstaff and Schwartz seem to just reuse the paths in &lt;a href=&#34;http://rfs.oxfordjournals.org/content/14/1/113.short&#34;&gt;their paper&lt;/a&gt;, and Glasserman himself, when presenting Longstaff-Schwartz method later in the book just use the same paths for the regression and to compute the Monte-Carlo mean value.&lt;br /&gt;&lt;br /&gt;How large is this bias? What is the correct methodology?&lt;br /&gt;&lt;br /&gt;I have tried with Sobol quasi random numbers to evaluate that bias on a simple Bermudan put option of maturity 180 days, exercisable at 30 days, 60 days, 120 days and 180 days using a Black Scholes volatility of 20% and a dividend yield of 6%. As a reference I use &lt;a href=&#34;http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;cad=rja&amp;amp;ved=0CDcQFjAA&amp;amp;url=http%3A%2F%2Fpapers.ssrn.com%2Fsol3%2Fpapers.cfm%3Fabstract_id%3D1648878&amp;amp;ei=9151UZ3pM4LZPZ-ugeAF&amp;amp;usg=AFQjCNFS9fdRJt9RoerSnb87YDIZmLcCtw&amp;amp;sig2=k8lHjhUe14ep4giVM5Mr5Q&amp;amp;bvm=bv.45512109,d.ZWU&#34;&gt;a finite difference solver based on TR-BDF2&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;I found it particularly difficult to evaluate it: should we use the same number of paths for the 2 methods or should we use the same number of paths for the monte carlo mean computation only? Should we use the same number of paths for regression and for monte carlo mean computation or should the monte carlo mean computation use much more paths?&lt;br /&gt;&lt;br /&gt;I have tried those combinations and was able to clearly see the bias only in one case: a large number of paths for the Monte-Carlo mean computation compared to the number of paths used for the regression using a fixed total number of paths of 256*1024+1, and 32*1024+1 paths for the regression.&lt;br /&gt;&lt;br /&gt;&lt;span style=&#34;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&#34;&gt;FDM price=2.83858387194312&lt;/span&gt;&lt;br /&gt;&lt;span style=&#34;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&#34;&gt;Longstaff discarded paths price=2.8385854695510426&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style=&#34;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&#34;&gt;Longstaff reused paths price=2.8386108892756847&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Those numbers are too good to be a real. If one reduces too much the total number of paths or the number of paths for the regression, the result is not precise enough to see the bias. For example, using 4K paths for the regression leads to 2.83770 vs 2.83767. Using 4K paths for regression and only 16K paths in total leads to 2.8383 vs 2.8387. Using 32K paths for regressions and increasing to 1M paths in total leads to 2.838539 vs 2.838546.&lt;br /&gt;&lt;br /&gt;For this example the Longstaff-Schwartz price is biased low, the slight increase due to path reuse is not very visible and most of the time does not deteriorate the overall accuracy. But as a result of reusing the paths, the Longstaff-Schwartz price might be higher than the real value.</description>
			</item>
			<item>
				<title>A Fast Exponential Function in Java</title>
				<link>https://31416.org/post/a-fast-exponential-function-in-java/</link>
				<pubDate>Fri, 19 Apr 2013 16:48:00 +0000</pubDate>
				<guid>https://31416.org/post/a-fast-exponential-function-in-java/</guid>
				<description>In finance, because one often dicretize the log process instead of the direct process for Monte-Carlo simulation, the Math.exp function can be called a lot (millions of times for a simulation) and can be a bottleneck. I have noticed that the simpler Euler discretization was for local volatility Monte-Carlo around 30% faster, because it avoids the use of Math.exp.&lt;br /&gt;&lt;br /&gt;Can we improve the speed of exp over the JDK one? At first it would seem that the JDK would just call either the processor exp using an &lt;a href=&#34;http://bad-concurrency.blogspot.co.uk/2012/08/arithmetic-overflow-and-intrinsics.html&#34;&gt;intrinsic function call&lt;/a&gt; and that should be difficult to beat. However what if one is ok for a bit lower accuracy? Could a simple &lt;a href=&#34;http://www.siam.org/books/ot99/OT99SampleChapter.pdf&#34;&gt;Chebyshev polynomial expansion&lt;/a&gt; be faster?&lt;br /&gt;&lt;br /&gt;Out of curiosity, I tried a Chebyshev polynomial expansion with 10 coefficients stored in a final double array. I computed the coefficient using a precise quadrature (Newton-Cotes) and end up with 1E-9, 1E-10 absolute and relative accuracy on [-1,1].&lt;br /&gt;&lt;br /&gt;Here are the results of a simple sum of 10M random numbers:&lt;br /&gt;&lt;br /&gt;&lt;span style=&#34;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&#34;&gt;0.75s for Math.exp sum=1.7182816693332244E7&lt;br /&gt;0.48s for ChebyshevExp sum=1.718281669341388E7&lt;br /&gt;0.40s for FastMath.exp sum=1.7182816693332244E7&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;So while this simple implementation is actually faster than Math.exp (but only works within [-1,1]), FastMath from Apache commons maths, that relies on a table lookup algorithm is just faster (in addition to being more precise and not limited to [-1,1]).&lt;br /&gt;&lt;br /&gt;Of course if I use only 5 coefficients, the speed is better, but the relative error becomes around 1e-4 which is unlikely to be satisfying for a finance application.&lt;br /&gt;&lt;br /&gt;&lt;span style=&#34;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&#34;&gt;0.78s for Math.exp sum=1.7182816693332244E7&lt;br /&gt;0.27s for ChebyshevExp sum=1.718193001875838E7&lt;br /&gt;0.40s for FastMath.exp sum=1.7182816693332244E7&lt;/span&gt;</description>
			</item>
			<item>
				<title>From Double Precision Normal Density to Double Precision Cumulative Normal Distribution</title>
				<link>https://31416.org/post/from-double-precision-normal-density-to-double-precision-cumulative-normal-distribution/</link>
				<pubDate>Tue, 02 Apr 2013 14:24:00 +0000</pubDate>
				<guid>https://31416.org/post/from-double-precision-normal-density-to-double-precision-cumulative-normal-distribution/</guid>
				<description>&lt;p&gt;Marsaglia in &lt;!-- raw HTML omitted --&gt;his paper on Normal Distribution&lt;!-- raw HTML omitted --&gt; made the same mistake I initially did while trying to verify &lt;!-- raw HTML omitted --&gt;the accuracy of the normal density&lt;!-- raw HTML omitted --&gt;.&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;In his table of values comparing the true value computed by Maple for some values of x to the values computed by Sun or Ooura erfc, he actually does not really use the same input for the comparison. One example is the last number: 16.6. 16.6 does not have an exact representation in double precision, even though it is displayed as 16.6 because of the truncation at machine epsilon precision. Using Python mpmath, one can see that:&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&amp;gt;&amp;gt;&amp;gt; mpf(-16.6)&lt;!-- raw HTML omitted --&gt;mpf(&amp;rsquo;-16.6000000000000014210854715202004&amp;rsquo;)&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;This is the more accurate representation if one goes beyond double precision (here 30 digits). And the value of the cumulative normal distribution is:&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&amp;gt;&amp;gt;&amp;gt; ncdf(-16.6)&lt;!-- raw HTML omitted --&gt;mpf(&amp;lsquo;3.4845465199503256054808152068743e-62&amp;rsquo;)&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;It is different from:&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&amp;gt;&amp;gt;&amp;gt; ncdf(mpf(&amp;quot;-16.6&amp;quot;))&lt;!-- raw HTML omitted --&gt;mpf(&amp;lsquo;3.48454651995040810217553910503186e-62&amp;rsquo;)&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;where in this case it is really evaluated around -16.6 (up to 30 digits precision). Marsaglia gives this second number as reference. But all the other algorithms will actually take as input the first input. It is more meaningful to compare results using the exact same input. Using human readable but computer truncated numbers is not the best.  The cumulative normal distribution will often be computed using some output of some calculation where one does not have an exact human readable input.&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;The standard code for Ooura and Schonfelder (as well as Marsaglia) algorithms for the cumulative normal distribution don&amp;rsquo;t use Cody&amp;rsquo;s trick to evaluate the exp(-x&lt;em&gt;x). This function appears in all those implementations because it is part of the dominant term in the usual expansions. Out of curiosity, I replaced this part with Cody trick. For Ooura I also made minor changes to make it work directly on the CND instead of going through the error function erfc indirection. Here are the results without the Cody trick (except for Cody):&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;and with it:&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;All 3 algorithms are now of similiar accuracy (note the difference of scale compared to the previous graph), with Schonfelder being a bit worse, especially for x &amp;gt;= -20. If one uses only easily representable numbers (for example -37, -36,75, -36,5, &amp;hellip;) in double precision then, of course, Cody trick importance won&amp;rsquo;t be visible and here is how the 3 algorithms would fare with or without Cody trick:&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;Schonfelder looks now worse than it actually is compared to Cody and Ooura.&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;To conclude, if someone claims that a cumulative normal distribution is up to double precision accuracy and it does not use any tricks to compute exp(-x&lt;/em&gt;x), then beware, it probably is quite a bit less than double precision.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Cracking the Double Precision Gaussian Puzzle</title>
				<link>https://31416.org/post/cracking-the-double-precision-gaussian-puzzle/</link>
				<pubDate>Fri, 22 Mar 2013 12:20:00 +0000</pubDate>
				<guid>https://31416.org/post/cracking-the-double-precision-gaussian-puzzle/</guid>
				<description>&lt;p&gt;In my &lt;a href=&#34;https://31416.org/post/a-double-precision-puzzle-with-the-gaussian/&#34;&gt;previous post&lt;/a&gt;, I stated that some library (SPECFUN by W.D. Cody) computes \(e^{-\frac{x^2}{2}}\) the following way:&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#f0f0f0;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-C&#34; data-lang=&#34;C&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;xsq &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06287e&#34;&gt;fint&lt;/span&gt;(x &lt;span style=&#34;color:#666&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#40a070&#34;&gt;1.6&lt;/span&gt;) &lt;span style=&#34;color:#666&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#40a070&#34;&gt;1.6&lt;/span&gt;;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;del &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; (x &lt;span style=&#34;color:#666&#34;&gt;-&lt;/span&gt; xsq) &lt;span style=&#34;color:#666&#34;&gt;*&lt;/span&gt; (x &lt;span style=&#34;color:#666&#34;&gt;+&lt;/span&gt; xsq);&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;result &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06287e&#34;&gt;exp&lt;/span&gt;(&lt;span style=&#34;color:#666&#34;&gt;-&lt;/span&gt;xsq &lt;span style=&#34;color:#666&#34;&gt;*&lt;/span&gt; xsq &lt;span style=&#34;color:#666&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#40a070&#34;&gt;0.5&lt;/span&gt;) &lt;span style=&#34;color:#666&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#06287e&#34;&gt;exp&lt;/span&gt;(&lt;span style=&#34;color:#666&#34;&gt;-&lt;/span&gt;del &lt;span style=&#34;color:#666&#34;&gt;*&lt;/span&gt;&lt;span style=&#34;color:#40a070&#34;&gt;0.5&lt;/span&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;&#xA;&lt;p&gt;where &lt;code class=&#34;code-inline language-C&#34;&gt;&lt;span style=&#34;color:#06287e&#34;&gt;fint&lt;/span&gt;(z)&lt;/code&gt; computes the floor of z.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Why 1.6?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;An integer divided by 1.6 will be an exact representation of the corresponding number in double: 1.6 because of 16 (dividing by 1.6 is equivalent to multiplying by 10 and dividing by 16 which is an exact operation). It also allows to have something very close to a rounding function: x=2.6 will make xsq=2.5, x=2.4 will make xsq=1.875, x=2.5 will make xsq=2.5. The maximum difference between x and xsq will be 0.625.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Local Volatility Delta &amp; Dynamic</title>
				<link>https://31416.org/post/local-volatility-delta--dynamic/</link>
				<pubDate>Thu, 29 Nov 2012 12:30:00 +0000</pubDate>
				<guid>https://31416.org/post/local-volatility-delta--dynamic/</guid>
				<description>This will be a very technical post, I am not sure that it will be very understandable by people not familiar with the implied volatility surface.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Something one notices when computing an option price under local volatility using a PDE solver, is how different is the Delta from the standard Black-Scholes Delta, even though the price will be very close for a Vanilla option. In deed, the Finite difference grid will have a different local volatility at each point and the Delta will take into account a change in local volatility as well.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;But this finite-difference grid Delta is also different from a standard numerical Delta where one just move the initial spot up and down, and takes the difference of computed prices. The numerical Delta will eventually include a change in implied volatility, depending if the surface is sticky-strike (vol will stay constant) or sticky-delta (vol will change). So the numerical Delta produced with a sticky-strike surface will be the same as the standard Black-Scholes Delta. In reality, what happens is that the local volatility is different when the spot moves up, if we recompute it: it is not static. The finite difference solver computes Delta with a static local volatility. If we call twice the finite difference solver with a different initial spot, we will reproduce the correct Delta, that takes into account the dynamic of the implied volatility surface.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Here how different it can be if the delta is computed from the grid (static local volatility) or numerically (dynamic local volatility) on an exotic trade:&lt;/div&gt;&lt;div class=&#34;separator&#34; style=&#34;clear: both; text-align: center;&#34;&gt;&lt;a href=&#34;http://3.bp.blogspot.com/-WW8ZE7urDGE/ULdHKNe_VXI/AAAAAAAAGKQ/JQ5Rd7wQYkk/s1600/static_localvol.png&#34; imageanchor=&#34;1&#34; style=&#34;margin-left: 1em; margin-right: 1em;&#34;&gt;&lt;img border=&#34;0&#34; height=&#34;235&#34; src=&#34;http://3.bp.blogspot.com/-WW8ZE7urDGE/ULdHKNe_VXI/AAAAAAAAGKQ/JQ5Rd7wQYkk/s320/static_localvol.png&#34; width=&#34;320&#34; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;This is often why people assume the local volatility model is wrong, not consistent. It is wrong if we consider the local volatility surface as static to compute hedges.&lt;/div&gt;</description>
			</item>
			<item>
				<title>GPU computing in Finance</title>
				<link>https://31416.org/post/gpu-computing-in-finance/</link>
				<pubDate>Mon, 15 Oct 2012 16:14:00 +0000</pubDate>
				<guid>https://31416.org/post/gpu-computing-in-finance/</guid>
				<description>&lt;p&gt;Very interesting presentation from Murex about their GPU computing. Some points were:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;GPU demand for mostly exotics pricing and greeks&lt;/li&gt;&#xA;&lt;li&gt;Local vol main model for EQD exotics. Local vol calibrated via PDE approach.&lt;/li&gt;&#xA;&lt;li&gt;Markov functional model becoming main model for IRD.&lt;/li&gt;&#xA;&lt;li&gt;Use of local regression instead of Longstaff Schwartz (or worse CVA like sim of sim).&lt;/li&gt;&#xA;&lt;li&gt;philox RNG from DE Shaw. But the presenter does not seem to know RNGs  very well (recommended Brownian Bridge for Mersenne Twister!).&lt;/li&gt;&#xA;&lt;li&gt;An important advantage of GPU is latency. Grid computing only improves throughput but not latency. GPU improves both.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;a href=&#34;http://nvidia.fullviewmedia.com/gtc2010/0923-a7-2032.html&#34;&gt;http://nvidia.fullviewmedia.com/gtc2010/0923-a7-2032.html&lt;/a&gt;&lt;/p&gt;</description>
			</item>
			<item>
				<title>Binary Voting</title>
				<link>https://31416.org/post/binary-voting/</link>
				<pubDate>Fri, 07 Sep 2012 17:21:00 +0000</pubDate>
				<guid>https://31416.org/post/binary-voting/</guid>
				<description>How many reports have you had to fill up with a number of stars to choose? How much useless time is spent on figuring the this number just because it is always very ambiguous?&lt;br /&gt;&lt;br /&gt;Some blogger wrote an interesting entry on &lt;a href=&#34;http://davidcelis.com/blog/2012/02/01/why-i-hate-five-star-ratings/&#34;&gt;Why I Hate Five Stars Reviews&lt;/a&gt;. Basically he advocates binary voting instead via like/dislike. Maybe a ternary system via like/dislike/don&#39;t care would be ok too.&lt;br /&gt;&lt;br /&gt;One coworker used to advocate the same for a similar reason: people reading those reports only pay attention to the extremes: the 5 stars or the 0 stars. So if you want to have a voice, you need to express it via 5 or 0, nothing in between.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;</description>
			</item>
			<item>
				<title>Adaptive Quadrature for Pricing European Option with Heston</title>
				<link>https://31416.org/post/adaptive-quadrature-for-pricing-european-option-with-heston/</link>
				<pubDate>Mon, 25 Jun 2012 12:50:00 +0000</pubDate>
				<guid>https://31416.org/post/adaptive-quadrature-for-pricing-european-option-with-heston/</guid>
				<description>The Quantlib code to evaluate the Heston integral for European options is quite nice. It proposes &lt;a href=&#34;http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=4&amp;amp;ved=0CGoQFjAD&amp;amp;url=http%3A%2F%2Fwww.math.uni-wuppertal.de%2F%7Ekahl%2Fpublications%2FNotSoComplexLogarithmsInTheHestonModel.pdf&amp;amp;ei=MkDoT8HHOaO_0QXS_6SeCQ&amp;amp;usg=AFQjCNFbAMQBLoKRd0BR_-HC0CkP4zrMtg&#34;&gt;Kahl &amp;amp; Jaeckel&lt;/a&gt; method as well as Gatheral method for the complex logarithm. It also contains expansions where it matters so that the resulting code is very robust. One minor issue is that it does not integrate both parts at the same time, and also does not propose Attari method for the Heston integral that is supposed to be more stable.&lt;br /&gt;&lt;br /&gt;I was surprised to find out that out of the money, short expiry options seemed badly mispriced. In the end I discovered it was just that it required sometimes more than 3500 function evaluations to have an accuracy of 1e-6.&lt;br /&gt;&lt;br /&gt;As this sounds a bit crazy, I thought that Jaeckel log transform was the culprit. In reality, it turned out that it was &lt;a href=&#34;http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CFMQFjAA&amp;amp;url=http%3A%2F%2Fusers.wpi.edu%2F%7Ewalker%2FMA510%2FHANDOUTS%2Fw.gander%2Cw.gautschi%2CAdaptive_Quadrature%2CBIT_40%2C2000%2C84-101.pdf&amp;amp;ei=U0HoT_HWBeXP0QW23O3xBw&amp;amp;usg=AFQjCNH4KRWMprUvL8yBPKRxO_sVNyc2Pg&#34;&gt;Gauss Lobatto Gander &amp;amp; Gautschi implementation&lt;/a&gt;. I tried the simplest algorithm in &lt;a href=&#34;http://www.ii.uib.no/%7Eterje/Papers/bit2003.pdf&#34;&gt;Espelid improved algorithms&lt;/a&gt;: modsim, an adaptive extrapolated Simpson method, and it was 4x faster for the same accuracy. That plus the fact that it worked out of the box (translated to Java) on my problem was impressive.&lt;br /&gt;&lt;br /&gt;Jaeckel log transform (to change the interval from 0,+inf to 0,1) works well, and seems to offer a slight speedup (10% to 15%) for around ATM options, mid to long term for the same accuracy. Unfortunately, it can also slow down by up to 50% the convergence for more OTM options or shorter expiries. So I am not so sure about its interest vs just cutting off the integration at phi=200.</description>
			</item>
			<item>
				<title>Why primitive arrays matter in Java</title>
				<link>https://31416.org/post/why-primitive-arrays-matter-in-java/</link>
				<pubDate>Wed, 29 Feb 2012 10:01:00 +0000</pubDate>
				<guid>https://31416.org/post/why-primitive-arrays-matter-in-java/</guid>
				<description>&lt;p&gt;In the past, I have seen that one could greatly improve performance of some Monte-Carlo simulation by using as much as possible &lt;code&gt;double[][]&lt;/code&gt; instead of arrays of objects.&lt;/p&gt;&#xA;&lt;p&gt;It was interesting to read &lt;a href=&#34;http://flavor8.com/index.php/2012/02/25/java-performance-autoboxing-and-data-structure-choice-obviously-matter-but-by-how-much/&#34;&gt;this blog post explaining why that happens&lt;/a&gt;: it is all about memory access.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Generating random numbers following a given discrete probability distribution</title>
				<link>https://31416.org/post/generating-random-numbers-following-a-given-discrete-probability-distribution/</link>
				<pubDate>Mon, 09 Jan 2012 00:14:00 +0000</pubDate>
				<guid>https://31416.org/post/generating-random-numbers-following-a-given-discrete-probability-distribution/</guid>
				<description>&lt;p&gt;I have never really thought very much about generating random numbers according to a precise discrete distribution, for example to simulate an unfair dice.&lt;/p&gt;&#xA;&lt;p&gt;In finance, we are generally interested in continuous distributions, where there is typically 2 ways:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the &lt;a href=&#34;http://en.wikipedia.org/wiki/Inverse_transform_sampling&#34;&gt;inverse transform&lt;/a&gt; (usually computed in a numerical way),&lt;/li&gt;&#xA;&lt;li&gt;and the &lt;a href=&#34;http://en.wikipedia.org/wiki/Rejection_sampling&#34;&gt;acceptance-rejection&lt;/a&gt; method, typically the &lt;a href=&#34;http://en.wikipedia.org/wiki/Ziggurat_algorithm&#34;&gt;ziggurat&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The inverse transform is often preferred, because it&amp;rsquo;s usable method for Quasi Monte-Carlo simulations while the acceptance rejection is not.&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;I would have thought about the simple way to generate random numbers according to a discrete distribution as first described &lt;a href=&#34;http://www.delicious.com/redirect?url=http%3A//blog.sigfpe.com/2012/01/lossless-decompression-and-generation.html&#34;&gt;here&lt;/a&gt;. But establishing a link with &lt;a href=&#34;http://en.wikipedia.org/wiki/Huffman_coding&#34;&gt;Huffman encoding&lt;/a&gt; is brilliant. Some better performing alternative (unrelated to Huffman) is offered &lt;a href=&#34;http://www.keithschwarz.com/darts-dice-coins/&#34;&gt;there&lt;/a&gt;.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Quant Interview &amp; Education</title>
				<link>https://31416.org/post/quant-interview--education/</link>
				<pubDate>Wed, 21 Dec 2011 17:37:00 +0000</pubDate>
				<guid>https://31416.org/post/quant-interview--education/</guid>
				<description>Recently, I interviewed someone for a quant position. I was very surprised to find out that someone who did one of the best master in probabilities and finance in France could not solve a very basic probability problem:&lt;br /&gt;&lt;br /&gt;&lt;div class=&#34;separator&#34; style=&#34;clear: both; text-align: left;&#34;&gt;&lt;a href=&#34;http://2.bp.blogspot.com/-64ejCSg9Y8o/TvIHEF4PgwI/AAAAAAAAFio/uxVwdwVnQ54/s1600/Screenshot+at+2011-12-21+17%253A18%253A28.png&#34; imageanchor=&#34;1&#34; style=&#34;margin-left: 1em; margin-right: 1em;&#34;&gt;&lt;img border=&#34;0&#34; height=&#34;43&#34; src=&#34;http://2.bp.blogspot.com/-64ejCSg9Y8o/TvIHEF4PgwI/AAAAAAAAFio/uxVwdwVnQ54/s400/Screenshot+at+2011-12-21+17%253A18%253A28.png&#34; width=&#34;400&#34; /&gt;&lt;/a&gt;&lt;/div&gt;This is accessible to someone with very little knowledge of probabilities &lt;br /&gt;&lt;br /&gt;When I asked this problem around to co-workers (who have all at least a master in a scientific subject), very few could actually answer it properly. Most of the time, I suspect it is because they did not dedicate enough time to do it properly, and wanted to answer it too quickly.&lt;br /&gt;&lt;br /&gt;It was more shocking that someone just out of school, with a major in probabilities could not answer that properly. It raises the question: what is all this education worth?&lt;br /&gt;&lt;br /&gt;The results were not better as soon as the question was not exactly like what students in those masters are used to, like for example, this simple stochastic calculus question:&lt;br /&gt;&lt;div class=&#34;separator&#34; style=&#34;clear: both; text-align: center;&#34;&gt;&lt;a href=&#34;http://2.bp.blogspot.com/-K9mO8qrp1Ow/TvIKO_MTOSI/AAAAAAAAFiw/igPGRdnFNEo/s1600/Screenshot+at+2011-12-21+17%253A19%253A11.png&#34; imageanchor=&#34;1&#34; style=&#34;margin-left: 1em; margin-right: 1em;&#34;&gt;&lt;img border=&#34;0&#34; src=&#34;http://2.bp.blogspot.com/-K9mO8qrp1Ow/TvIKO_MTOSI/AAAAAAAAFiw/igPGRdnFNEo/s1600/Screenshot+at+2011-12-21+17%253A19%253A11.png&#34; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;My opinion is that, today in our society, people study for too long. The ideal system for me would be one where people learn a lot in math/physics the first 2 years of university, and then have more freedom in their education, much like a doctorate.&lt;br /&gt;&lt;br /&gt;We still offered the job to this person, because live problem solving is not the most important criteria. Other qualities like seriousness and motivation are much more valuable.</description>
			</item>
			<item>
				<title>Good &amp; Popular Algorithms are Simple</title>
				<link>https://31416.org/post/good--popular-algorithms-are-simple/</link>
				<pubDate>Thu, 17 Nov 2011 12:28:00 +0000</pubDate>
				<guid>https://31416.org/post/good--popular-algorithms-are-simple/</guid>
				<description>I recently tried to minimise a function according to some constraints. One popular method to minimise a function in several dimensions is &lt;a href=&#34;http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CB0QFjAA&amp;amp;url=http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FNelder%25E2%2580%2593Mead_method&amp;amp;ei=PfHETsKYDdG9sAb_q935Cw&amp;amp;usg=AFQjCNEVD7lMV4buMbVCJ3fuiyupPA6B1w&#34;&gt;Nelder-Mead Simplex&lt;/a&gt;. It is quite simple, so simple that I programmed it in Java in 1h30, including a small design and a test. It helped that the original paper from Nelder-Mead is very clear:&lt;br /&gt;&lt;div class=&#34;separator&#34; style=&#34;clear: both; text-align: center;&#34;&gt;&lt;a href=&#34;http://3.bp.blogspot.com/-glZ52IB0SkA/TsTxF4VmyFI/AAAAAAAAFhw/zSDQ0Het9MU/s1600/neldermeadalgo.png&#34; imageanchor=&#34;1&#34; style=&#34;margin-left: 1em; margin-right: 1em;&#34;&gt;&lt;img border=&#34;0&#34; height=&#34;184&#34; src=&#34;http://3.bp.blogspot.com/-glZ52IB0SkA/TsTxF4VmyFI/AAAAAAAAFhw/zSDQ0Het9MU/s320/neldermeadalgo.png&#34; width=&#34;320&#34; /&gt;&lt;/a&gt;&lt;/div&gt;However the main issue is that it works only for unconstrained problems. Nelder and Mead suggested to add a penalty, but in practice this does not work so well. For constrained problems, there is an adaptation of the original idea by Box (incredible name for a constrained method) that he called &lt;a href=&#34;http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CB4QFjAA&amp;amp;url=http%3A%2F%2Fcomjnl.oxfordjournals.org%2Fcontent%2F8%2F1%2F42.full.pdf&amp;amp;ei=EvLETqz6LcTvsgbN4I2ADA&amp;amp;usg=AFQjCNHq6JD1ik4rTLO4a1v4G9adbGMRzQ&#34;&gt;the Complex method&lt;/a&gt;, a deliberate pun to the Nelder-Mead Simplex method. The basic idea is to reset the trial point near the fixed boundary if it goes outside. Now this took me much longer to program, as the paper is not as clear, even if the method is still relatively simple. But worst, after a day of deciphering the paper and programming the complex method, I find out that it does not works so well: it does not manage to minimise a simple multidimensional quadratic with a simple bound constraint: f(X)=sum(X)^2 with X &amp;gt;= 0 where X is an N-dimensional vector. In the end, I don&#39;t want to work with such a simple function, but it is a good simple test to see if the method is really working or not. Here is how the function looks with N=2:&lt;br /&gt;&lt;div class=&#34;separator&#34; style=&#34;clear: both; text-align: center;&#34;&gt;&lt;a href=&#34;http://2.bp.blogspot.com/-ncMKzKcYdtA/TsT_TEyNHDI/AAAAAAAAFiA/er1pQWNcHXc/s1600/quadfull.png&#34; imageanchor=&#34;1&#34; style=&#34;margin-left: 1em; margin-right: 1em;&#34;&gt;&lt;img border=&#34;0&#34; height=&#34;320&#34; src=&#34;http://2.bp.blogspot.com/-ncMKzKcYdtA/TsT_TEyNHDI/AAAAAAAAFiA/er1pQWNcHXc/s320/quadfull.png&#34; width=&#34;302&#34; /&gt;&lt;/a&gt;&lt;/div&gt;And if we restrict to x,y &amp;gt;= 0 it becomes:&lt;br /&gt;&lt;div class=&#34;separator&#34; style=&#34;clear: both; text-align: center;&#34;&gt;&lt;a href=&#34;http://1.bp.blogspot.com/-msyZ9eQ7GnM/TsT_d36SD7I/AAAAAAAAFiI/Kt4QBwjsAE8/s1600/quadpart.png&#34; imageanchor=&#34;1&#34; style=&#34;margin-left: 1em; margin-right: 1em;&#34;&gt;&lt;img border=&#34;0&#34; height=&#34;304&#34; src=&#34;http://1.bp.blogspot.com/-msyZ9eQ7GnM/TsT_d36SD7I/AAAAAAAAFiI/Kt4QBwjsAE8/s320/quadpart.png&#34; width=&#34;320&#34; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;I suspected an error in my program, so I decided to try with scilab, that has also the Box method as part of their &lt;a href=&#34;http://help.scilab.org/docs/5.3.3/en_US/neldermead.html&#34;&gt;neldermead_search&lt;/a&gt; functionality. Scilab also failed to compute the minimum in 8 dimensions of my simple quadratic. &lt;br /&gt;&lt;div class=&#34;separator&#34; style=&#34;clear: both; text-align: center;&#34;&gt;&lt;a href=&#34;http://4.bp.blogspot.com/-vO6JhSwv3MU/TsT1ge1H96I/AAAAAAAAFh4/DTnsYjnMeHE/s1600/neldermeadalgo1.png&#34; imageanchor=&#34;1&#34; style=&#34;margin-left: 1em; margin-right: 1em;&#34;&gt;&lt;img border=&#34;0&#34; height=&#34;320&#34; src=&#34;http://4.bp.blogspot.com/-vO6JhSwv3MU/TsT1ge1H96I/AAAAAAAAFh4/DTnsYjnMeHE/s320/neldermeadalgo1.png&#34; width=&#34;265&#34; /&gt;&lt;/a&gt;&lt;/div&gt;I tried various settings, without ever obtaining a decent result (I expect to find a value near 0).&lt;br /&gt;&lt;br /&gt;There is another algorithm that can find a global minimum, also very popular: the &lt;a href=&#34;http://www.icsi.berkeley.edu/%7Estorn/TR-95-012.pdf&#34;&gt;Differential Evolution&lt;/a&gt;. At first, being a genetic algorithm, you would think it would be complicated to write. But no, the main loop is around 20 lines.&lt;br /&gt;&lt;div class=&#34;separator&#34; style=&#34;clear: both; text-align: center;&#34;&gt;&lt;a href=&#34;http://4.bp.blogspot.com/-cNeeYo8EQeQ/TsUB7Ek6rQI/AAAAAAAAFiQ/PTc4qwwAa7E/s1600/dealgo.png&#34; imageanchor=&#34;1&#34; style=&#34;margin-left: 1em; margin-right: 1em;&#34;&gt;&lt;img border=&#34;0&#34; height=&#34;320&#34; src=&#34;http://4.bp.blogspot.com/-cNeeYo8EQeQ/TsUB7Ek6rQI/AAAAAAAAFiQ/PTc4qwwAa7E/s320/dealgo.png&#34; width=&#34;297&#34; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Those 20 lines are a bit more difficult than Nelder-Mead, but still, when I saw that, I understood that &#34;this is a classic algorithm&#34;. And it does work with constraints easily. How to do this is explained well in K. Price book &#34;Differential Evolution&#34;, and takes only a few lines of code. Here is the result I got in dimension 29:&lt;br /&gt;&lt;span style=&#34;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; font-size: x-small;&#34;&gt;dim=29 min=1.2601854176573729E-12 genMax=412 x=[3.340096901536317E-8, 8.889252404343621E-8, 7.163904251807348E-10, 9.71847877381699E-9, 2.7423324674150668E-8, 2.4022269439114537E-9, 1.7336434478718816E-11, 7.244238163901778E-9, 1.0013136274729337E-8, 7.412154679865083E-9, 5.4694460144807974E-9, 2.3682413086417524E-9, 4.241739250073559E-7, 4.821920889534676E-10, 2.115396281722523E-9, 8.750883007882899E-8, 2.512011485133975E-9, 4.811507109129279E-9, 1.0752997894113096E-7, 5.120475258343548E-9, 8.404448964497456E-9, 4.1062290228305595E-9, 1.7030766521603753E-8, 5.589430643552073E-9, 8.237098544820173E-10, 3.5796523161196554E-9, 5.186299547466997E-9, 2.430326342762937E-7, 5.493850433494286E-9]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;It works well, although there is quite a bit of parameters. I noticed that the strategy was especially important.</description>
			</item>
			<item>
				<title>SIMD and Mersenne-Twister</title>
				<link>https://31416.org/post/simd-and-mersenne-twister/</link>
				<pubDate>Sat, 05 Feb 2011 13:18:00 +0000</pubDate>
				<guid>https://31416.org/post/simd-and-mersenne-twister/</guid>
				<description>&lt;p&gt;Since 2007, there is a new kind of Mersenne-Twister (MT) that exploits SIMD architecture, the &lt;a href=&#34;http://www.math.sci.hiroshima-u.ac.jp/%7Em-mat/MT/SFMT/&#34;&gt;SFMT&lt;/a&gt;. The Mersenne-Twister has set quite a standard in random number generation for Monte-Carlo simulations, even though it has flaws.&lt;/p&gt;&#xA;&lt;p&gt;I was wondering if SFMT improved the performance over MT for a Java implementation. There is actually on the same page a decent Java port of the original algorithm. When I ran it, it ended up slower by more than 20% than the classical Mersenne-Twister (32-bit) on a 64-bit JDK 1.6.0.23 for Windows.&lt;/p&gt;</description>
			</item>
			<item>
				<title>The CUDA Performance Myth</title>
				<link>https://31416.org/post/the-cuda-performance-myth/</link>
				<pubDate>Mon, 03 Jan 2011 16:07:00 +0000</pubDate>
				<guid>https://31416.org/post/the-cuda-performance-myth/</guid>
				<description>&lt;p&gt;There is an &lt;a href=&#34;http://arxiv.org/PS_cache/arxiv/pdf/0901/0901.0638v4.pdf&#34;&gt;interesting&lt;/a&gt; article on how to generate efficiently the inverse of the normal cumulative distribution on the GPU. This is useful for Monte-Carlo simulations based on normally distributed variables.&lt;/p&gt;&#xA;&lt;p&gt;Another result of the paper is a method (breakless algorithm) to compute it apparently faster than the very good &lt;a href=&#34;http://www.mth.kcl.ac.uk/~shaww/web_page/papers/Wichura.pdf&#34;&gt;Wichura&amp;rsquo;s AS241&lt;/a&gt; algorithm on the CPU as well keeping a similar precision. The key is to avoid branches (if-then) at the cost of not avoiding log() calls. As the algorithm is very simple, I decided to give it a try in Java.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Another Look at Java Matrix Libraries</title>
				<link>https://31416.org/post/another-look-at-java-matrix-libraries/</link>
				<pubDate>Mon, 29 Nov 2010 12:45:00 +0000</pubDate>
				<guid>https://31416.org/post/another-look-at-java-matrix-libraries/</guid>
				<description>&lt;p&gt;A while ago, &lt;a href=&#34;https://31416.org/post/the-pain-of-java-matrix-libraries&#34;&gt;I was already looking&lt;/a&gt; for a good Java Matrix library, complaining that there does not seem any real good one where development is still active: the 2 best ones are in my opinion &lt;a href=&#34;http://math.nist.gov/javanumerics/jama/&#34;&gt;Jama&lt;/a&gt; and &lt;a href=&#34;http://dsd.lbl.gov/~hoschek/colt/&#34;&gt;Colt&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Recently I tried to &lt;a href=&#34;http://www.wilmott.com/detail.cfm?articleID=345&#34;&gt;price options via RBF&lt;/a&gt; (radial basis functions) based on &lt;a href=&#34;http://papers.ssrn.com/sol3/papers.cfm?abstract_id=1648878&#34;&gt;TR-BDF2&lt;/a&gt; time stepping.&#xA;This is a problem where one needs to do a few matrix multiplications and inverses (or better, LU solve) in a loop. The size of the matrix is typically 50x50 to 100x100, and one can loop between 10 and 1000 times.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Hull American Option Price Fallacies</title>
				<link>https://31416.org/post/hull-american-option-price-fallacies/</link>
				<pubDate>Fri, 15 May 2009 16:01:00 +0000</pubDate>
				<guid>https://31416.org/post/hull-american-option-price-fallacies/</guid>
				<description>&lt;a onblur=&#34;try {parent.deselectBloggerImageGracefully();} catch(e) {}&#34; href=&#34;http://4.bp.blogspot.com/_9RyqGT46Fbk/Sg13q_LZDrI/AAAAAAAADNE/WHy0J8iNZoY/s1600-h/hull_american_r04_v20_q02_p49.png&#34;&gt;&lt;img style=&#34;margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 320px; height: 240px;&#34; src=&#34;http://4.bp.blogspot.com/_9RyqGT46Fbk/Sg13q_LZDrI/AAAAAAAADNE/WHy0J8iNZoY/s320/hull_american_r04_v20_q02_p49.png&#34; alt=&#34;&#34; id=&#34;BLOGGER_PHOTO_ID_5336052713901330098&#34; border=&#34;0&#34; /&gt;&lt;/a&gt;&lt;br /&gt;Hull says American put is best exercised immediately and american call is optimal at expiry like a european. Is this really true?&lt;br /&gt;&lt;br /&gt;At first it seems really clever and model show clearly this. But if we change the market assumptions only a tiny bit, everything falls down.&lt;br /&gt;&lt;br /&gt;I could not detail everything in a blog post so I created a &lt;a href=&#34;http://31416.appspot.com/static/hullamerican/hull_american_price.html&#34;&gt;static web page about it&lt;/a&gt;. Everything was produced in Java using algorithm found in popular books and graphs through JFreeChart.</description>
			</item>
			<item>
				<title>Bachelier vs. Black</title>
				<link>https://31416.org/post/bachelier-vs.-black/</link>
				<pubDate>Mon, 23 Mar 2009 17:58:00 +0000</pubDate>
				<guid>https://31416.org/post/bachelier-vs.-black/</guid>
				<description>&lt;a onblur=&#34;try {parent.deselectBloggerImageGracefully();} catch(e) {}&#34; href=&#34;http://4.bp.blogspot.com/_9RyqGT46Fbk/ScfCRxmTocI/AAAAAAAACzk/5_lPpPc7LzU/s1600-h/bachelier_vs_black_normal.png&#34;&gt;&lt;img style=&#34;margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 400px; height: 300px;&#34; src=&#34;http://4.bp.blogspot.com/_9RyqGT46Fbk/ScfCRxmTocI/AAAAAAAACzk/5_lPpPc7LzU/s400/bachelier_vs_black_normal.png&#34; alt=&#34;&#34; id=&#34;BLOGGER_PHOTO_ID_5316431495761732034&#34; border=&#34;0&#34; /&gt;&lt;/a&gt;&lt;br /&gt;Black and Scholes gives a strange result for the price of a binary option under high volatility.  You will learn here how to simulate a stock price evolution using Java, and how to show it using JFreeChart library. It starts with more complex concepts (don&#39;t be afraid) and goes done towards simpler things.&lt;br /&gt;&lt;br /&gt;I could not write all that in a blog format, so I created a old HTML page about it &lt;a href=&#34;http://31416.appspot.com/static/bachblack/Bachelier_vs_Black.html&#34;&gt;here&lt;/a&gt; and a &lt;a href=&#34;http://31416.appspot.com/static/bachblack/Bachelier_vs_Black.pdf&#34;&gt;PDF version&lt;/a&gt;.&lt;br /&gt;&lt;span style=&#34;text-decoration: underline;&#34;&gt;&lt;/span&gt;</description>
			</item>
	</channel>
</rss>
