Skip to main content

Posts

Showing posts from August, 2015

Conversion with PERL on the server side

var punycode = new function Punycode() { // This object converts to and from puny-code used in IDN // // punycode.ToASCII ( domain ) // // Returns a puny coded representation of "domain". // It only converts the part of the domain name that // has non ASCII characters. I.e. it dosent matter if // you call it with a domain that already is in ASCII. // // punycode.ToUnicode (domain) // // Converts a puny-coded domain name to unicode. // It only converts the puny-coded parts of the domain name. // I.e. it dosent matter if you call it on a string // that already has been converted to unicode. // // this.utf16 = { // The utf16-class is necessary to convert from javascripts  internal character representation to unicode and back. decode:function(input){ var output = [], i=0, len=input.length,value,extra; while (i < len) { value = input.charCodeAt(i++)...

How to save (large) data generated from simulations

The following is a simple example of a much larger simulation that I want to run Define some processes norTheta [ mu_ , sigma_ ] := Random [ NormalDistribution [ mu , sigma ]] ; norPi [ mu_ , sigma_ ] := Random [ NormalDistribution [ mu , sigma ]] ; thetaNext [ thetaNow_ ] := thetaNow + ( - lambdaTheta * ( thetaNow - thetaBar ) * deltaT + sigmaTheta * norTheta [ 0 , 1 ] * Sqrt [ deltaT ]) ; piNext [ piNow_ , thetaNow_ ] := piNow + ( - lambdaPi * ( piNow - thetaNow ) * deltaT + sigmaPi * norPi [ 0 , 1 ] * Sqrt [ deltaT ]) ;   Then define some parameters   lambdaTheta = 0.07 ; thetaBar = 0.02 ; sigmaTheta = 0.012 ; lambdaPi = 1.0 ; sigmaPi = 0.0125 ;     Then simulate the system   steps = 252 ; T = 50 ; deltaT = 1 / steps ; // N Maturity = T * steps ; process = Transpose [ NestList [{ piNext [ # [[ 1 ]] , # [[ 2 ]]] , thetaNext [ # [[ 2 ]]]} &, { 0.02 , 0.02 } , Maturity ]] ...