Tag Archives: Maths

Cumulative Normal Distribution in Q/KDB+

I have implemented the numerical approximation for the normal cumulative distribution function(cdf) here. Normal cdf is very important in financial mathematics because of its applications, one of them being in Black Scholes pricing. Mathematically, can be expressed as : Q … Continue reading

Posted in Pricing, Q, Regression | Tagged , | 2 Comments

Greatest Common Divisor in Q/KDB+

Euclid’s algorithm : Recursive definition of the gcd function using Euclid’s algorithm is : function gcd(a, b) { if (b = 0) return a else return gcd(b, a mod b) } Solution in Q : g:{$[y=0;:x;:g[y;x mod y]];} Results : … Continue reading

Posted in Q | Tagged , , | Leave a comment

Factorial Program

Q Solution 1:  factorial:{prd 1+til x} Q Solution 2: n:5 do[-1+f:r:n;r*:f-:1] r 120 The solution 2 is referred from Execution Control chapter in Q for Mortals. Results : factorial[5] 120

Posted in Q | Tagged , , | 1 Comment