You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: hypg_inv.m
    path of file: ./repos/malini/Codes/FC_EC_calculation code/DynamicFC/jplv7/distrib
    
    the code of the file until where you have to start completion: function  k = hypg_inv(p,n,K,N)
% PURPOSE: hypergeometric inverse (quantile) function
%---------------------------------------------------
% USAGE:     k = hypg_inv(p,n,K,N)
% where:     p = a vector
%        n,K,N = parameters of the distribution
%---------------------------------------------------
% RETURNS:
%        The smallest integer k so that P(X <= k) >= p.
%        a vector of probabilities from the distribution      
% --------------------------------------------------
% SEE ALSO: hypg_d, hypg_cdf, hypg_rnd, hypg_inv
%---------------------------------------------------

%QHYPGEO  The hypergeometric inverse cdf
%
%        k = qhypg(p,n,K,N))
%

    
function  k = hypg_inv(p,n,K,N)
% PURPOSE: hypergeometric inverse (quantile) function
%---------------------------------------------------
% USAGE:     k = hypg_inv(p,n,K,N)
% where:     p = a vector
%        n,K,N = parameters of the distribution
%---------------------------------------------------
% RETURNS:
%        The smallest integer k so that P(X <= k) >= p.
%        a vector of probabilities from the distribution      
% --------------------------------------------------
% SEE ALSO: hypg_d, hypg_cdf, hypg_rnd, hypg_inv
%---------------------------------------------------

%QHYPGEO  The hypergeometric inverse cdf
%
%        k = qhypg(p,n,K,N))
%
%        Gives the smallest integer k so that P(X <= k) >= p.

%       Anders Holtsberg, 18-11-93
%       Copyright (c) Anders Holtsberg
% documentation changed to match the econometrics toolbox
% by LeSage

% The algorithm contains a nice vectorization trick which
% relies on the fact that if two elements in a vector
% are exactely the same then matlab's routine SORT sorts them
% into the order they had. Do not change this, Mathworks!

if max([length(n) length(K) length(N)]) > 1
   error('Sorry, this is not implemented');
end