Generate sample of a random process with given correlation function












1












$begingroup$


My task is in numerical modeling evolution of a random quantity.
For this, I need first to generate a multitude of sample sequences that correspond to a predefined correlation function. In other words, considering the process $a(mathbf{x})$ is a function of N-dimensional vector $mathbf{x}=(x_1,ldots,x_N)$ and supposing its stationarity, i.e. $langle{}a^{ast}(mathbf{x}')a(mathbf{x}'')rangle=K(mathbf{x}''-mathbf{x}')$, which way can I generate random samples of $a(mathbf{x})$ that obey $K(mathbf{x}''-mathbf{x}')$ ?










share|cite|improve this question











$endgroup$












  • $begingroup$
    Do you have any more specific requirements other than just the covariance function, e.g. that the process should be Gaussian?
    $endgroup$
    – Ian
    Sep 26 '16 at 20:15










  • $begingroup$
    It would be great if the only requirement is stationarity, however, Gaussianity can be added to first approximation.
    $endgroup$
    – MikhailShmulevich
    Sep 27 '16 at 8:35










  • $begingroup$
    I mean without something else it will be impossible to specify how to draw samples.
    $endgroup$
    – Ian
    Sep 27 '16 at 10:41










  • $begingroup$
    Ok. To be more specific, suppose that the process is Gaussian.
    $endgroup$
    – MikhailShmulevich
    Sep 27 '16 at 20:58
















1












$begingroup$


My task is in numerical modeling evolution of a random quantity.
For this, I need first to generate a multitude of sample sequences that correspond to a predefined correlation function. In other words, considering the process $a(mathbf{x})$ is a function of N-dimensional vector $mathbf{x}=(x_1,ldots,x_N)$ and supposing its stationarity, i.e. $langle{}a^{ast}(mathbf{x}')a(mathbf{x}'')rangle=K(mathbf{x}''-mathbf{x}')$, which way can I generate random samples of $a(mathbf{x})$ that obey $K(mathbf{x}''-mathbf{x}')$ ?










share|cite|improve this question











$endgroup$












  • $begingroup$
    Do you have any more specific requirements other than just the covariance function, e.g. that the process should be Gaussian?
    $endgroup$
    – Ian
    Sep 26 '16 at 20:15










  • $begingroup$
    It would be great if the only requirement is stationarity, however, Gaussianity can be added to first approximation.
    $endgroup$
    – MikhailShmulevich
    Sep 27 '16 at 8:35










  • $begingroup$
    I mean without something else it will be impossible to specify how to draw samples.
    $endgroup$
    – Ian
    Sep 27 '16 at 10:41










  • $begingroup$
    Ok. To be more specific, suppose that the process is Gaussian.
    $endgroup$
    – MikhailShmulevich
    Sep 27 '16 at 20:58














1












1








1





$begingroup$


My task is in numerical modeling evolution of a random quantity.
For this, I need first to generate a multitude of sample sequences that correspond to a predefined correlation function. In other words, considering the process $a(mathbf{x})$ is a function of N-dimensional vector $mathbf{x}=(x_1,ldots,x_N)$ and supposing its stationarity, i.e. $langle{}a^{ast}(mathbf{x}')a(mathbf{x}'')rangle=K(mathbf{x}''-mathbf{x}')$, which way can I generate random samples of $a(mathbf{x})$ that obey $K(mathbf{x}''-mathbf{x}')$ ?










share|cite|improve this question











$endgroup$




My task is in numerical modeling evolution of a random quantity.
For this, I need first to generate a multitude of sample sequences that correspond to a predefined correlation function. In other words, considering the process $a(mathbf{x})$ is a function of N-dimensional vector $mathbf{x}=(x_1,ldots,x_N)$ and supposing its stationarity, i.e. $langle{}a^{ast}(mathbf{x}')a(mathbf{x}'')rangle=K(mathbf{x}''-mathbf{x}')$, which way can I generate random samples of $a(mathbf{x})$ that obey $K(mathbf{x}''-mathbf{x}')$ ?







stochastic-processes numerical-methods






share|cite|improve this question















share|cite|improve this question













share|cite|improve this question




share|cite|improve this question








edited Sep 26 '16 at 20:16









Ian

68.9k25392




68.9k25392










asked Sep 26 '16 at 20:12









MikhailShmulevichMikhailShmulevich

264




264












  • $begingroup$
    Do you have any more specific requirements other than just the covariance function, e.g. that the process should be Gaussian?
    $endgroup$
    – Ian
    Sep 26 '16 at 20:15










  • $begingroup$
    It would be great if the only requirement is stationarity, however, Gaussianity can be added to first approximation.
    $endgroup$
    – MikhailShmulevich
    Sep 27 '16 at 8:35










  • $begingroup$
    I mean without something else it will be impossible to specify how to draw samples.
    $endgroup$
    – Ian
    Sep 27 '16 at 10:41










  • $begingroup$
    Ok. To be more specific, suppose that the process is Gaussian.
    $endgroup$
    – MikhailShmulevich
    Sep 27 '16 at 20:58


















  • $begingroup$
    Do you have any more specific requirements other than just the covariance function, e.g. that the process should be Gaussian?
    $endgroup$
    – Ian
    Sep 26 '16 at 20:15










  • $begingroup$
    It would be great if the only requirement is stationarity, however, Gaussianity can be added to first approximation.
    $endgroup$
    – MikhailShmulevich
    Sep 27 '16 at 8:35










  • $begingroup$
    I mean without something else it will be impossible to specify how to draw samples.
    $endgroup$
    – Ian
    Sep 27 '16 at 10:41










  • $begingroup$
    Ok. To be more specific, suppose that the process is Gaussian.
    $endgroup$
    – MikhailShmulevich
    Sep 27 '16 at 20:58
















$begingroup$
Do you have any more specific requirements other than just the covariance function, e.g. that the process should be Gaussian?
$endgroup$
– Ian
Sep 26 '16 at 20:15




$begingroup$
Do you have any more specific requirements other than just the covariance function, e.g. that the process should be Gaussian?
$endgroup$
– Ian
Sep 26 '16 at 20:15












$begingroup$
It would be great if the only requirement is stationarity, however, Gaussianity can be added to first approximation.
$endgroup$
– MikhailShmulevich
Sep 27 '16 at 8:35




$begingroup$
It would be great if the only requirement is stationarity, however, Gaussianity can be added to first approximation.
$endgroup$
– MikhailShmulevich
Sep 27 '16 at 8:35












$begingroup$
I mean without something else it will be impossible to specify how to draw samples.
$endgroup$
– Ian
Sep 27 '16 at 10:41




$begingroup$
I mean without something else it will be impossible to specify how to draw samples.
$endgroup$
– Ian
Sep 27 '16 at 10:41












$begingroup$
Ok. To be more specific, suppose that the process is Gaussian.
$endgroup$
– MikhailShmulevich
Sep 27 '16 at 20:58




$begingroup$
Ok. To be more specific, suppose that the process is Gaussian.
$endgroup$
– MikhailShmulevich
Sep 27 '16 at 20:58










1 Answer
1






active

oldest

votes


















1





+50







$begingroup$

I'll assume you have some finite grid ${x_1,dots, x_n}$ of x values on which you want to draw samples. In this case, $a$ is simply an n-dimensional multivariate gaussian with covariance matrix $C_{ij}=K(x_i-x_j)$. Many libraries (for example numpy) have builtin functionality to sample from such distributions.



However, if you need to take many samples, this can be rather slow. One trick is to do a PCA and keep only the first few components. That is, let $v_i,lambda_i$ be the eigenvectors/eigenvalues of $C$, with $lambda_1gelambda_2ge...$. Now fix $K$ and consider the random veector $a_K=sum_{ileq K} sqrt{lambda_i} X_iv_i$ where $X_i$ are iid unit normals. If $K=n$ (so we include all eigenvalues)then it is not hard to show that $a$ satisfies the desired covariance structure (in fact it is a gaussian process).



Often there exists $K<<n$ so that, for example $sum_{ileq K} lambda_i/sum_ilambda_i>.95$. In this case, the truncated sum will be an excellent approximation to samples from the true distribution, and will be much faster, because each sample of $a_K$ requires $K$ independent gaussian samples, rather than the $n$ correlated samples required by the naive method.



Note this can also be done in the continuous case, and is called a Karhonen-Loeve decomosition.






share|cite|improve this answer











$endgroup$














    Your Answer





    StackExchange.ifUsing("editor", function () {
    return StackExchange.using("mathjaxEditing", function () {
    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
    StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
    });
    });
    }, "mathjax-editing");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "69"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    noCode: true, onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f1942646%2fgenerate-sample-of-a-random-process-with-given-correlation-function%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1





    +50







    $begingroup$

    I'll assume you have some finite grid ${x_1,dots, x_n}$ of x values on which you want to draw samples. In this case, $a$ is simply an n-dimensional multivariate gaussian with covariance matrix $C_{ij}=K(x_i-x_j)$. Many libraries (for example numpy) have builtin functionality to sample from such distributions.



    However, if you need to take many samples, this can be rather slow. One trick is to do a PCA and keep only the first few components. That is, let $v_i,lambda_i$ be the eigenvectors/eigenvalues of $C$, with $lambda_1gelambda_2ge...$. Now fix $K$ and consider the random veector $a_K=sum_{ileq K} sqrt{lambda_i} X_iv_i$ where $X_i$ are iid unit normals. If $K=n$ (so we include all eigenvalues)then it is not hard to show that $a$ satisfies the desired covariance structure (in fact it is a gaussian process).



    Often there exists $K<<n$ so that, for example $sum_{ileq K} lambda_i/sum_ilambda_i>.95$. In this case, the truncated sum will be an excellent approximation to samples from the true distribution, and will be much faster, because each sample of $a_K$ requires $K$ independent gaussian samples, rather than the $n$ correlated samples required by the naive method.



    Note this can also be done in the continuous case, and is called a Karhonen-Loeve decomosition.






    share|cite|improve this answer











    $endgroup$


















      1





      +50







      $begingroup$

      I'll assume you have some finite grid ${x_1,dots, x_n}$ of x values on which you want to draw samples. In this case, $a$ is simply an n-dimensional multivariate gaussian with covariance matrix $C_{ij}=K(x_i-x_j)$. Many libraries (for example numpy) have builtin functionality to sample from such distributions.



      However, if you need to take many samples, this can be rather slow. One trick is to do a PCA and keep only the first few components. That is, let $v_i,lambda_i$ be the eigenvectors/eigenvalues of $C$, with $lambda_1gelambda_2ge...$. Now fix $K$ and consider the random veector $a_K=sum_{ileq K} sqrt{lambda_i} X_iv_i$ where $X_i$ are iid unit normals. If $K=n$ (so we include all eigenvalues)then it is not hard to show that $a$ satisfies the desired covariance structure (in fact it is a gaussian process).



      Often there exists $K<<n$ so that, for example $sum_{ileq K} lambda_i/sum_ilambda_i>.95$. In this case, the truncated sum will be an excellent approximation to samples from the true distribution, and will be much faster, because each sample of $a_K$ requires $K$ independent gaussian samples, rather than the $n$ correlated samples required by the naive method.



      Note this can also be done in the continuous case, and is called a Karhonen-Loeve decomosition.






      share|cite|improve this answer











      $endgroup$
















        1





        +50







        1





        +50



        1




        +50



        $begingroup$

        I'll assume you have some finite grid ${x_1,dots, x_n}$ of x values on which you want to draw samples. In this case, $a$ is simply an n-dimensional multivariate gaussian with covariance matrix $C_{ij}=K(x_i-x_j)$. Many libraries (for example numpy) have builtin functionality to sample from such distributions.



        However, if you need to take many samples, this can be rather slow. One trick is to do a PCA and keep only the first few components. That is, let $v_i,lambda_i$ be the eigenvectors/eigenvalues of $C$, with $lambda_1gelambda_2ge...$. Now fix $K$ and consider the random veector $a_K=sum_{ileq K} sqrt{lambda_i} X_iv_i$ where $X_i$ are iid unit normals. If $K=n$ (so we include all eigenvalues)then it is not hard to show that $a$ satisfies the desired covariance structure (in fact it is a gaussian process).



        Often there exists $K<<n$ so that, for example $sum_{ileq K} lambda_i/sum_ilambda_i>.95$. In this case, the truncated sum will be an excellent approximation to samples from the true distribution, and will be much faster, because each sample of $a_K$ requires $K$ independent gaussian samples, rather than the $n$ correlated samples required by the naive method.



        Note this can also be done in the continuous case, and is called a Karhonen-Loeve decomosition.






        share|cite|improve this answer











        $endgroup$



        I'll assume you have some finite grid ${x_1,dots, x_n}$ of x values on which you want to draw samples. In this case, $a$ is simply an n-dimensional multivariate gaussian with covariance matrix $C_{ij}=K(x_i-x_j)$. Many libraries (for example numpy) have builtin functionality to sample from such distributions.



        However, if you need to take many samples, this can be rather slow. One trick is to do a PCA and keep only the first few components. That is, let $v_i,lambda_i$ be the eigenvectors/eigenvalues of $C$, with $lambda_1gelambda_2ge...$. Now fix $K$ and consider the random veector $a_K=sum_{ileq K} sqrt{lambda_i} X_iv_i$ where $X_i$ are iid unit normals. If $K=n$ (so we include all eigenvalues)then it is not hard to show that $a$ satisfies the desired covariance structure (in fact it is a gaussian process).



        Often there exists $K<<n$ so that, for example $sum_{ileq K} lambda_i/sum_ilambda_i>.95$. In this case, the truncated sum will be an excellent approximation to samples from the true distribution, and will be much faster, because each sample of $a_K$ requires $K$ independent gaussian samples, rather than the $n$ correlated samples required by the naive method.



        Note this can also be done in the continuous case, and is called a Karhonen-Loeve decomosition.







        share|cite|improve this answer














        share|cite|improve this answer



        share|cite|improve this answer








        edited Dec 13 '18 at 23:03

























        answered Dec 13 '18 at 21:01









        Mike HawkMike Hawk

        1,595110




        1,595110






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Mathematics Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            Use MathJax to format equations. MathJax reference.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f1942646%2fgenerate-sample-of-a-random-process-with-given-correlation-function%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            How to change which sound is reproduced for terminal bell?

            Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

            Can I use Tabulator js library in my java Spring + Thymeleaf project?