<< QuantLib`
<< Statistics`

?SVJDModel

\(mlst = {mbas = 
          SVJDModel[40, 0.08, 0.06, 0.15, 0.15, 0.15, 4, 0, 0, 0, 
            0], 
mVt = 
          SVJDModel[40, 0.08, 0.06, 0.2, 0.15, 0.15, 4, 0, 0, 0, 
            0], 
msigmav = 
          SVJDModel[40, 0.08, 0.06, 0.15, 0.3, 0.15, 4, 0, 0, 0, 
            0], 
mrho = 
          SVJDModel[40, 0.08, 0.06, 0.15, 0.15, 0.15, 4, 0.1, 0, 0, 
            0], 
mjump = 
          SVJDModel[40, 0.08, 0.06, Sqrt[0.0125], 0.2, Sqrt[0.0125], 
            4, 0, 2, 0, 0.07]}; \)

ilst = Table[AmericanOption[K, 0.25, PutOption], {K, 38, 42}]

(analtbl = {{0.379, 0.672, 1.095, 1.653, 2.343}, {0.582, 
              0.916, 1.358, 1.911, 2.571}, {0.374, 0.658, 1.077, 
              1.638, 2.335}, {0.373, 0.668, 1.094, 1.655, 
              2.347}, {0.360, 0.626, 1.030, 1.588, 2.292}}) // 
      TableForm

kf[s_, anti_] := 
      Keyfigures[i, m, Method -> MonteCarlo, 
        AntitheticPaths -> anti, ControlVariate -> True, 
        Samples -> s]

blok[s_, anti_, 
        resim_:  100] := (
lst = 
          Table[{Value, StandardError} /. 
              kf[s, anti], {resim}]; 
{anal, 
          lst[[1, 1]], lst[[1, 2]], 
          Mean[lst[[All, 1]]] - anal, 
          StandardDeviation[
            lst[[All, 1]] - 
              anal]}
)

comb = Flatten[Outer[{#2, #1} &, mlst, ilst], 1];

oneblok[
        no_] := (oneblok[
            no] = (anal = Flatten[analtbl][[no]]; 
            i = comb[[no, 1]]; 
            m = comb[[no, 2]]; 
            blok[10000, True, 100]))

start = SessionTime[]

oneblok[1]

oneblok[2]

oneblok[3]

oneblok[4]

oneblok[5]

oneblok[6]

oneblok[7]

oneblok[8]

oneblok[9]

oneblok[10]

oneblok[11]

oneblok[12]

oneblok[13]

oneblok[14]

oneblok[15]

oneblok[16]

oneblok[17]

oneblok[18]

oneblok[19]

oneblok[20]

oneblok[21]

oneblok[22]

oneblok[23]

oneblok[24]

oneblok[25]

slut = SessionTime[]; slut - start

\({"\begin{tabular}{l} 0.379 \\ 0.380764 \\ 0.0031547 \\ 0.00135972 \\ 0.00283261 \end{tabular} ", "\begin{tabular}{l} 0.672 \\ 0.668521 \\ 0.00434639 \\ -0.000772954 \\ 0.00451867 \end{tabular} ", "\begin{tabular}{l} 1.095 \\ 1.08837 \\ 0.00643971 \\ -0.00285161 \\ 0.00633172 \end{tabular} ", "\begin{tabular}{l} 1.653 \\ 1.6477 \\ 0.0080797 \\ -0.00329734 \\ 0.00840206 \end{tabular} ", "\begin{tabular}{l} 2.343 \\ 2.32595 \\ 0.0104223 \\ -0.00833228 \\ 0.0105455 \end{tabular} ", "\begin{tabular}{l} 0.582 \\ 0.591771 \\ 0.00447169 \\ 0.00115977 \\ 0.00432744 \end{tabular} ", "\begin{tabular}{l} 0.916 \\ 0.91631 \\ 0.00595801 \\ -0.00200497 \\ 0.00634286 \end{tabular} ", "\begin{tabular}{l} 1.358 \\ 1.35577 \\ 0.00766071 \\ -0.00350372 \\ 0.00771846 \end{tabular} ", "\begin{tabular}{l} 1.911 \\ 1.91142 \\ 0.00978762 \\ -0.00669885 \\ 0.00926877 \end{tabular} ", "\begin{tabular}{l} 2.571 \\ 2.56422 \\ 0.0116866 \\ -0.00694296 \\ 0.0106244 \end{tabular} ", "\begin{tabular}{l} 0.374 \\ 0.376742 \\ 0.00260692 \\ 0.00113028 \\ 0.00320697 \end{tabular} ", "\begin{tabular}{l} 0.658 \\ 0.658352 \\ 0.00426255 \\ -0.000456597 \\ 0.00435209 \end{tabular} ", "\begin{tabular}{l} 1.077 \\ 1.06791 \\ 0.00600975 \\ -0.00467587 \\ 0.00628393 \end{tabular} ", "\begin{tabular}{l} 1.638 \\ 1.63149 \\ 0.00749407 \\ -0.00955337 \\ 0.00808901 \end{tabular} ", "\begin{tabular}{l} 2.335 \\ 2.31426 \\ 0.00991359 \\ -0.0118106 \\ 0.00916696 \end{tabular} ", "\begin{tabular}{l} 0.373 \\ 0.379025 \\ 0.00335726 \\ 0.00231477 \\ 0.00292549 \end{tabular} ", "\begin{tabular}{l} 0.668 \\ 0.67357 \\ 0.00441863 \\ 0.000340736 \\ 0.00370428 \end{tabular} ", "\begin{tabular}{l} 1.094 \\ 1.09307 \\ 0.00625276 \\ -0.0024858 \\ 0.00565423 \end{tabular} ", "\begin{tabular}{l} 1.655 \\ 1.6565 \\ 0.00821696 \\ -0.00397622 \\ 0.00858969 \end{tabular} ", "\begin{tabular}{l} 2.347 \\ 2.33654 \\ 0.00986413 \\ -0.00477903 \\ 0.011067 \end{tabular} ", "\begin{tabular}{l} 0.36 \\ 0.359716 \\ 0.00276957 \\ 0.00252744 \\ 0.00391248 \end{tabular} ", "\begin{tabular}{l} 0.626 \\ 0.621998 \\ 0.00408163 \\ 0.00157056 \\ 0.00505156 \end{tabular} ", "\begin{tabular}{l} 1.03 \\ 1.03883 \\ 0.00479596 \\ 0.000141756 \\ 0.00666403 \end{tabular} ", "\begin{tabular}{l} 1.588 \\ 1.58841 \\ 0.00738676 \\ -0.00160629 \\ 0.00926126 \end{tabular} ", "\begin{tabular}{l} 2.292 \\ 2.3165 \\ 0.00949592 \\ -0.00514644 \\ 0.0122489 \end{tabular} "}\)

exp = Table[ExportTeXString[List /@ oneblok[i]], {i, 1, 25}]

stmp = OpenWrite["c:\\cand\\LSMSVJD-FDBates.txt"]; 
    WriteString[stmp, exp]; Close[stmp]

Export["XXX.nb", NotebookGet[]]

Print["Nu må der slukkes uden at gemme..."]