function bias = func_bias_Trigo(approx_type, min_m, max_m, precision, Qstar, param, kast, lawtype)
% Computes the bias for all trigonometric spaces of dimension min_m to max_m.
% approx_type:  type of approximation space
% min_m, max_m: min and max dimension of the approximation space
% precision:    requested precision on the bias
% Qstar:   k*k  true transition matrix
% param:   k*.  parameters of the emission densities
% kast:         order of the HMM
% lawtype: cell with k strings, type of emission laws

%% Calculates mEstim such that the error ||f^* - f^*_mEstim||_F is smaller
% than precision.
mEstim = max_m-1;
First = true;
meshlength = 1;
while(First || norm(fstar - fm, 'fro')/meshlength > precision)
	% Increase space dimension until the error on f^* is smaller than the threshold.
    mEstim = mEstim+1;
    
    [~, basePM, OEstim, fstar, Mestim] = func_emissionProjection_Trigo(mEstim, Qstar, param, kast, lawtype);
    fm = OEstim' * basePM;
    meshlength = size(basePM, 2);
    
    First = false;
end

%% Calculates the approximate bias, that is the L2-difference between g_m
% and g_mEstim for m=min_m:max_m.
bias = zeros(max_m-min_m+1,1);
Mtemp = zeros(mEstim, mEstim, mEstim);
for m=min_m:max_m
    [~, ~, ~, ~, Mm] = func_emissionProjection_Trigo(m, Qstar, param, kast, lawtype);
    Mtemp(1:m, 1:m, 1:m) = Mm;
        
    bias(m - min_m + 1) = sqrt(sum(sum(sum( (Mtemp-Mestim).*(Mtemp-Mestim) ))));
end
