####This function calculates f_{theta_i}(Xj) where Xj is a data point and theta_i is a support point of the iterate f. ####and hence it retruns a matrix of dimension n = length(X) x m = length(S). EvaluateMatf <- function(S,K,X, Mat0){ S <- sort(S) m <- length(S) n <- length(X) #Xs <- sort(X) #matrix(0,nrow=n,ncol=m) if(m==1){ Matf <- matrix(0,nrow=n,ncol=1) } else{ Matf <- Mat0[1:n,1:m] } for(i in 1:n){ Matf[i,] <- (K/S^{K})*ifelse(S >= X[i], (S-X[i])^{K-1},0) } Matf }