# Calls Smolyak_Elem_Isotrop.jl and Smolyak_Grid.jl to produce a Smolyak GRID
# Scales the dimensions given an input vector.

function Gen_Smolyak(d,mu,max_min,weight,sd::Float64=2)

#Generate Smolyak element

Smol_elem=Smolyak_Elem_Isotrop(d,mu)

Grid=Smolyak_Grid(d,mu,Smol_elem)

Smol_grid=zeros(size(Grid))

for i=1:d
    max_t=max_min[i,1]
    min_t=max_min[i,2]
    Smol_grid[:,i]=(Grid[:,i].+1)/2 .*(max_t-min_t) .+min_t
end

if weight==1
    weights=zeros(size(Smol_grid,1))
    for i=1:size(Smol_grid,1)
        vec_t=Grid[i,:]
        prob=Distributions.pdf(MvNormal(6,1/sd),vec_t)
        weights[i]=prob
    end
    weights=weights./sum(weights).*size(Smol_grid,1)

else
    weights=ones(size(Smol_grid,1))
end


return Smol_grid,weights
end
