Serving the Quantitative Finance Community

 
User avatar
Tinkerz1
Topic Author
Posts: 1
Joined: December 12th, 2008, 9:59 am

Numerical Laplace Transform in C# to an array

July 3rd, 2010, 3:20 pm

Numerical Laplace Transform in C#I am looking for some help in converting the below code from the website below into a formula that can use an array http://www.codeproject.com/KB/recipes/L ... aspxpublic static double Transform(FunctionDelegate F, double s) { const int DefaultIntegralN = 5000; double du = 0.5 / (double)DefaultIntegralN; double y = - F(0) / 2.0; double u = 0; double limit = 1.0 - 1e-10; while (u < limit) { u += du; y += 2.0 * Math.Pow(u, s - 1) * F(-Math.Log(u)); u += du; y += Math.Pow(u, s - 1) * F(-Math.Log(u)); } return 2.0 * y * du / 3.0; } double F(double t) { return 1.0 / Math.Exp(2.0*t); } ... double LCalc = Laplace.Transform(F, 2);///////////////////////////////////////////////////////////This is my assumption, then I would like to understand more about this formula, and try to explain what I want to do with itpublic static double Transform([]Myarray, double s) { const int DefaultIntegralN = 5000; int Arraylength =Myarray.Length; double y = - Myarray[0] / 2.0; double u = 0; double limit = 1.0 - 1e-10; while (u < Arraylength) { u += 1; y += 2.0 * Math.Pow(Myarray[u-1], s - 1) * -Math.Log(Myarray[u-1]); u += 1; y += Math.Pow(Myarray[u-1], s - 1) * Math.Log(Myarray[u-1]); } return 2.0 * y * 1 / 3.0; }//Called by double LCalc = Laplace.Transform(MyArray, 2);They array will be of type double and contain real numbers.I am looking to use this formula to compare and adjust a numbers post and pre-processingThe context is(All numbers stored in an array)Original number>extract laplaceSend to Haar TransformArray post Haar> extract laplaceCompare both resultsAdjust Post Haar result.///////////////////////////After reading up on Laplace, I am assuming the 2 results can be compared, and if the properties of post Haar transform have changed, I can adjust the post Haar transform.Thanks for reading, hope you can understand and helpTinkerz
 
User avatar
Cuchulainn
Posts: 23029
Joined: July 16th, 2004, 7:38 am

Numerical Laplace Transform in C# to an array

July 3rd, 2010, 4:09 pm

QuoteI am looking for some help in converting the below code from the website below into a formula that can use an array I am having difficulty: what is the desired output from your new function and what is the given input? If we know that then the rest becomes easier. In particular, the relation between the delegate and myArray. My guess is that you want to call the LT with an array instead of a function delegate and these numbers are the discretised function values at mesh points. Don't you need a factory to create an array of function from a delegate based on x abscissae values?
Last edited by Cuchulainn on July 2nd, 2010, 10:00 pm, edited 1 time in total.
 
User avatar
Tinkerz1
Topic Author
Posts: 1
Joined: December 12th, 2008, 9:59 am

Numerical Laplace Transform in C# to an array

July 3rd, 2010, 4:50 pm

I have an array of data that has been passed through a high bypass filter.After reading up on LP, I thought it was the solution.If I run LP on the High Bypass filter data, then pass the High Bypass filter data to a Haar wavelet to get the frequency.I can then check via LP post High Bypass filter data and post Haar wavelet to check how much has changed via LPT moments.But I must be mislead, its sounds like its going to get very complicatedTinkerz
 
User avatar
PavelG
Posts: 0
Joined: April 21st, 2011, 2:43 pm

Numerical Laplace Transform in C# to an array

December 20th, 2011, 12:29 pm

I need to calculate inverse laplace transform at zero, but this algorithm is infinit at zero http://www.codeproject.com/KB/recipes/L ... forms.aspx / How to handke this case? Thx!!!!
 
User avatar
AVt
Posts: 90
Joined: December 29th, 2001, 8:23 pm

Numerical Laplace Transform in C# to an array

December 22nd, 2011, 1:53 pm

If L is the Laplace transform of a function f, then the inverse Laplace transformof L gives you back the function f, thus you want f(0) or may be the limit.There is however no need, that f(0) exists: for taking f = log you will haveL(s) = -(const + log(s)) / s for any positive s, but for the inverse you areasking for log(0).In case you are sure it exists (say: f(t) = exp(-t^2)) you may try to approximatef(0) by some f(epsilon), say epsilon = 1E-10.