julia> X = MvNormal(ones(2), [1 0.5;0.5 1])
FullNormal(
dim: 2
μ: [1.0,1.0]
Σ: 2x2 Array{Float64,2}:
1.0 0.5
0.5 1.0
)
julia> rand(X, 4)
2x4 Array{Float64,2}:
0.228904 0.326973 2.19096 -0.130484
2.49441 0.872328 -0.283637 -0.397549
Is there a function or functionality equivalent or similar to R's mvrnorm?I want to fit a linear model to a bunch of `x` and `y` points, and then generate new *random* `x2` and `y2` points that would follow the distribution of the fitted model. So unlike `predict`, I need the new points to be random and not **just** follow the linear model's regression line. These point's randomness should be similar to that of the original `x` and `y` data.
--
You received this message because you are subscribed to the Google Groups "julia-stats" group.
To unsubscribe from this group and stop receiving emails from it, send an email to julia-stats...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
using GLM, ASCIIPlots, DataFrames
n = 25
x = linspace(0,10,n)
y = 2x .+ 3randn(n)
d = DataFrame(X = x, Y = y)
f = lm(Y ~ X, d)
f2 = MvNormal(coef(f),vcov(f))
nl = 10000
ba = rand(f2,nl)
b = vec(ba[1,:])
a = vec(ba[2,:])
xl = linspace(0,10,nl)
yl = a.*xl .+ b
scatterplot(x,y, sym = '*')
scatterplot(xl,yl, sym = '*')