function [x, basePM, Ostar, fstar, Mth, Mhat, Phat, Nhat, lhat, Qhat, Ohat] = func_prepareForPM(m, Y, approx_type, Qstar, param, kast, lawtype)
% Initializes the basis and estimators corresponding to the approximation space of dimension m.

%% True emission laws and their projection onto the approximation space of dimension m.
if strcmp(approx_type, 'trigo')
    [x, basePM, Ostar, fstar, Mth] = func_emissionProjection_Trigo(m, Qstar, param, kast, lawtype);
elseif strcmp(approx_type, 'histo')
    [x, basePM, Ostar, fstar, Mth] = func_emissionProjection_Histo(m, Qstar, param, kast, lawtype);
end

%% Empirical estimators computation.
if strcmp(approx_type, 'trigo')
    [Mhat, Phat, Nhat, lhat] = func_empiricalEstimators_Trigo(m, Y);
elseif strcmp(approx_type, 'histo')
    [Mhat, Phat, Nhat, lhat] = func_empiricalEstimators_Histo(m, Y);
end

%% Starting parameters: 1 state, uniform emission law.
[Qhat, Ohat] = func_firstInit(m, x, basePM);
