ITE / code / H_I_D / utilities / estimate_HRenyi_constant.m

Full commit
%function [] = estimate_HRenyi_constant()
%Estimates the additive constants of the Renyi entropy estimators 'Renyi_kNN_1tok', 'Renyi_kNN_S', 'Renyi_MST' and 'Renyi_GSF', for a fixed dimension (d below). In certain cases these constants can also be important. Here, they are precomputed via Monte-Carlo simulations; the result is saved and becomes available in 'HRenyi_kNN_1tok_estimation.m', 'HRenyi_kNN_S_estimation.m', 'HRenyi_MST_estimation.m' and 'HRenyi_GSF_estimation.m'.
%Copyright (C) 2012 Zoltan Szabo ("", "szzoli (at) cs (dot) elte (dot) hu")
%This file is part of the ITE (Information Theoretical Estimators) Matlab/Octave toolbox.
%ITE is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
%the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
%This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
%MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
%You should have received a copy of the GNU General Public License along with ITE. If not, see <>.

%clear start:
    clear all;

    %name of the Renyi entropy estimator:
        cost_name = 'Renyi_kNN_1tok';
        %cost_name = 'Renyi_kNN_S';
        %cost_name = 'Renyi_MST';
        %cost_name = 'Renyi_GSF';
        d = 1;
    num_of_samples = 10000;%number of samples for a fixed run
    num_of_MC_runs = 50;   %number of Monte-Carlo runs
%initialize cost object:
    mult = 1;
    co = H_initialization(cost_name,mult);%the value of 'mult' is irrelevant (=not used) below.

switch cost_name
    case {'Renyi_kNN_1tok','Renyi_kNN_S','Renyi_MST','Renyi_GSF'}
            alp = co.alpha; 
            gam = d * (1-alp);
            sum_of_normalizedL = 0;      

        for k = 1 : num_of_MC_runs
            Y = rand(d,num_of_samples);%uniform distribution, U([0,1]^d)
                    %L = compute_length_HRenyi_kNN_1tok(Y,co);
		    %L = compute_length_HRenyi_kNN_S(Y,co);
                    %L = compute_length_HRenyi_MST(Y,co);
                    %L = compute_length_HRenyi_GSF(Y,co);
            sum_of_normalizedL = sum_of_normalizedL + L / (num_of_samples^(1-gam/d) ); 
            if mod(k,10)==1

        constant = sum_of_normalizedL / num_of_MC_runs;
        FN = filename_of_HRenyi_constant(d,co);
        disp('Error: cost name=?');