# Function to generate a clustered grid using time separated method

# Inputs:

#=
-simulation_in: Simulated states to be clustered

# This is the order of the simulated series
#
# Rlag   = simulation_in(:,1);                       % Interest Rate
# ylag   = simulation_in(:,2);                       % Output
# er     = simulation_in(:,3);                       % Monetary Shock
# z      = simulation_in(:,4);                       % Productivity
# g      = simulation_in(:,5);                       % Gov. expenditure

-CN: Number of draws
=#

# Outputs:
#=
-grid_out: CLuster centers
=#

#---------------------------------------------------------

function tsga_grid(simulation_in::Array{Float64,2},M_in::Int64)

obs,vars=size(simulation_in);
grid_out=zeros(M_in,vars);
step = div(obs,M_in);

for ii = 1:M_in
    grid_out[ii,:] = simulation_in[step*ii,:];
end


return grid_out
end
