Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intervention on multivariate normal distribution #197

Open
ga72kud opened this issue Mar 24, 2022 · 0 comments
Open

Intervention on multivariate normal distribution #197

ga72kud opened this issue Mar 24, 2022 · 0 comments

Comments

@ga72kud
Copy link

ga72kud commented Mar 24, 2022

I am trying to use following univariate distribution case to transform it into a multivariate distribution case:

α=categorical([0.3, 0.7])
function x_(rng)
  #α=categorical([0.1, .9])
  if(α(rng)==1)
    x=normal(rng, 0.3, .1)
  elseif(α(rng)==2)
    x=normal(rng, -0.3, .1)
  elseif(α(rng)==3)
    x=normal(rng, 0.0, .01)
  end
end
AM_SAMPLES=10000
x = ciid(x_)
samples=[rand(x) for i=1:AM_SAMPLES]
display(histogram!(samples, subplot=1))

x_interv=replace(x, α=>categorical([0.7, 0.2, 0.1]))

I am wondering how to use mvnormal (Omega multivariate distributions do not work for me). I used instead the Distributions.jl MvNormal function.

α=categorical([0.3, 0.7])
function x_(rng)
  if(α(rng)==1)
    rand(MvNormal([-2.0;-4.0], [1.0 0.0;0.0 1.0]))
  elseif(α(rng)==2)
    rand(MvNormal([2.0;-1.0], [1.0 0.0;0.0 1.0]))
  else
    rand(MvNormal([3.0;6.0], [1.0 0.0;0.0 1.0]))
  end
end
AM_SAMPLES=500
x = ciid(x_)
samples=[rand(x) for i=1:AM_SAMPLES]

This example worked for me. But I am wondering why I need rand(...) inside the function x_

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant