function [out] = f_predict(X1,X2,beta_mixing,beta_kernel,tau,threshold,type)
    
    % infer dimensions
    n        = size(X1,1);
    R        = size(beta_mixing,3);
    
    if strcmp(type,'mean')
        pred_mean = zeros(n,R);
        
        for r = 1:R
            pred_mean(:,r) = f_pred_mean(X1,X2,beta_mixing(:,:,r),beta_kernel(:,:,r));
        end
        out = pred_mean;
        
    elseif strcmp(type,'variance')
        
        pred_variance = zeros(n,R);
        
        for r = 1:R
            pred_variance(:,r) = f_pred_var(X1,X2,beta_mixing(:,:,r),beta_kernel(:,:,r),tau(:,r));
        end
        out = pred_variance;
        
    elseif strcmp(type,'cdf')
        
        cdf = zeros(n,R);
        if R>1
            for r = 1:R
                cdf(:,r) = f_pred_cdf(X1,X2,beta_mixing(:,:,r),beta_kernel(:,:,r),tau(:,r),threshold);
            end
        else
            cdf = f_pred_cdf(X1,X2,beta_mixing,beta_kernel,tau,threshold); 
        end
        out = cdf; 
    
    elseif strcmp(type,'CRPS')
        CRPS = zeros(R,1);
        if R>1
            for r = 1:R
                CRPS(r,1) = f_pred_CPRS(threshold,X1,X2,beta_mixing(:,:,r),beta_kernel(:,:,r),tau(:,r));
            end
        else
            CRPS = f_pred_CPRS(threshold,X1,X2,beta_mixing,beta_kernel,tau);
        end
        out = CRPS;  
    end

end

