X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=octave_packages%2Fga-0.10.0%2Ffitscalingrank.m;fp=octave_packages%2Fga-0.10.0%2Ffitscalingrank.m;h=65dee7e657ddad5c2eccd192a8960b30a24f1b87;hb=f5f7a74bd8a4900f0b797da6783be80e11a68d86;hp=0000000000000000000000000000000000000000;hpb=1705066eceaaea976f010f669ce8e972f3734b05;p=CreaPhase.git diff --git a/octave_packages/ga-0.10.0/fitscalingrank.m b/octave_packages/ga-0.10.0/fitscalingrank.m new file mode 100644 index 0000000..65dee7e --- /dev/null +++ b/octave_packages/ga-0.10.0/fitscalingrank.m @@ -0,0 +1,55 @@ +## Copyright (C) 2008, 2009 Luca Favatella +## +## This program 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 2 of the License, or +## (at your option) any later version. +## +## This program 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 this program; If not, see . + +## Author: Luca Favatella +## Version: 1.3.3 + +function expectation = fitscalingrank (scores, nParents) + nr_scores = rows (scores); + r(1, 1:nr_scores) = ranks (scores(1:nr_scores, 1)); + #TODO + #ranks ([7,2,2]) == [3.0,1.5,1.5] + #is [3,1,2] (or [3,2,1]) useful? + expectation_wo_nParents(1, 1:nr_scores) = arrayfun (@(n) 1 / sqrt (n), r); + expectation(1, 1:nr_scores) = \ + (nParents / sum (expectation_wo_nParents)) * \ + expectation_wo_nParents; +endfunction + + +## number of input arguments +# TODO + +## number of output arguments +# TODO + +## type of arguments +# TODO + +# TODO + +%!shared scores, nParents, expectation +%! scores = rand (20, 1); +%! nParents = 32; +%! expectation = fitscalingrank (scores, nParents); +%!assert (sum (expectation), nParents, 1e-9); +%!test +%! [trash index_min_scores] = min (scores); +%! [trash index_max_expectation] = max (expectation); +%! assert (index_min_scores, index_max_expectation); +%!test +%! [trash index_max_scores] = max (scores); +%! [trash index_min_expectation] = min (expectation); +%! assert (index_max_scores, index_min_expectation); \ No newline at end of file