在r中旋转2d多元正态分布

时间:2016-03-04 19:16:20

标签: r statistics

假设我有一个2d正态分布,由协方差矩阵和中心定义。如何围绕原点旋转此分布?

例如:

theta = 90*pi/180 #Angle in radians
mu2 = c(mu[1]*cos(theta) - mu[2]*sin(theta),mu[2]*cos(theta) + mu[1]*sin(theta))
plot(mvrnorm(n=n, mu=mu2, Sigma=Sigma))

旋转分布的中心点相对容易:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>Kendo UI Snippet</title>

    <link rel="stylesheet" href="http://kendo.cdn.telerik.com/2016.1.112/styles/kendo.common.min.css" />
    <link rel="stylesheet" href="http://kendo.cdn.telerik.com/2016.1.112/styles/kendo.rtl.min.css" />
    <link rel="stylesheet" href="http://kendo.cdn.telerik.com/2016.1.112/styles/kendo.silver.min.css" />
    <link rel="stylesheet" href="http://kendo.cdn.telerik.com/2016.1.112/styles/kendo.mobile.all.min.css" />

    <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
    <script src="http://kendo.cdn.telerik.com/2016.1.112/js/kendo.all.min.js"></script>
    <style type="text/css">
        a {
            cursor: pointer;
            text-decoration: underline;
        }
        .k-grid-update {
            display: none;
        }
    </style>
</head>
<body>
    <script id="row-template" type="text/x-kendo-tmpl">
        <a onclick="display('#=address#')">#=firstName#</a>
    </script>
    <script id="popup-editor" type="text/x-kendo-template">
        #=address#
    </script>
    <div id="grid"></div>
    <script>
        $("#grid").kendoGrid({
            columns: [
              { field: "id" },
              { field: "firstName", template: kendo.template($("#row-template").html()) },
              { field: "lastName" },
              { command: [{ name: "edit", text: { edit: "Address", cancel: "Close", update: "Close" } }]
              }
            ],
            dataSource: {
                data: [
                  { id: 1, firstName: "Jane", lastName: "Doe", address: "123 Street" },
                  { id: 2, firstName: "John", lastName: "Doe", address: "456 Street" }
                ],
                schema: {
                    model: { id: "id" }
                }
            },
            editable: {
                mode: "popup",
                window: { title: 'Address' },
                template: kendo.template($("#popup-editor").html())
            }
        });

        function display(address) {
            alert(address);
        }
    </script>
</body>
</html>

但是如何更改Sigma以旋转分布的方向?

0 个答案:

没有答案