title: In Julia using StochasticPrograms.jl and using @sampler micro, how to define a sampler which matches a 2 dimensional @uncertain variable?
body: <p>This matter is partially discussed here:
  <a href="https://stackoverflow.com/questions/71090512/in-julia-using-stochasticprograms-jl-package-how-can-i-get-the-sampler-object-a">In Julia using StochasticPrograms.jl package how can I get the @sampler object as a n*m matrix not a vector?</a>
  But there are significant new issues in this question:</p>
  <p>In the julia programming language I use StochasticPrograms.jl package to model a two stage stochastic problem. I use @sampler object to develop scenarios and random values.</p>
  <p>I have a two dimensional uncertain variable</p>
  <pre><code>@uncertain d[1:2, 1:2]
  </code></pre>
  <p>and I want to define a scenario in which values are sampled from different normal distributions.</p>
  <pre><code>@sampler ss = begin
          N::MvNormal     
          ss(µ, Σ) = new(MvNormal(µ, Σ))    
      @sample Scenario begin
          x = rand(sampler.N) 
          return @scenario  d = reshape(x,2,2)
      end
  end
  
  μ=[4,5,3,4];
  Σ= Diagonal([1,2,1,1.5]);
  </code></pre>
  <p>when I run the model by :</p>
  <pre><code>sp = instantiate(sm, ss(µ, Σ), 5)
  </code></pre>
  <p>I see this error</p>
  <pre><code>At untitled-5f4bcc7b395b3178d0e16e18a0962f0c:16: `@uncertain(d[1:2, 1:2])`: @uncertain declarations of type `@uncertain ξ[i = ..., j = ..., ...]` only support scenarios of type `Scenario` with Array or DenseAxisArray as underlying data, given scenario is: 
   Scenario with probability 0.2
    d: [5.100576528402207 4.89202743661476; 5.050253673984235 5.836340864424617].
   Use a matching `@scenario` call to generate scenarios or consider declaring a custom scenario type.
  error(::String, ::String) at error.jl:42
  _macro_error(macroname::Symbol, args::Vector{Expr}, source::LineNumberNode, str::String) at macros.jl:1390
  (::StochasticPrograms.var&quot;#_error#656&quot;)(x::Expr, str::String) at stage.jl:93
  #396 at untitled-5f4bcc7b395b3178d0e16e18a0962f0c:16 [inlined]
  (::var&quot;#396#412&quot;)(model::Model, stage::NamedTuple{(), Tuple{}}, scenario::Scenario{NamedTuple{(:d,), Tuple{Matrix{Float64}}}}) at none:0
  
  </code></pre>
  <p>This is strange because in the error what is presented as d is a two dimensional matrix matching the uncertain.</p>
  <p>I put below what I do to solve this problem but it is a silly method.</p>
  <pre><code>@uncertain d11 d12 d21 d22
  
  @sampler SimpleSampler = begin
      N::MvNormal # Normal distribution
      SimpleSampler(µ, Σ) = new(MvNormal(µ, Σ))
          @sample Scenario begin
              x = rand(sampler.N)
              return @scenario d11 = x[1] d12 = x[2] d21 = x[3] d22 = x[4]
          end
  end
  </code></pre>
  <p>Is there any work around for this?</p>