X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?p=CreaPhase.git;a=blobdiff_plain;f=octave_packages%2Fstatistics-1.1.3%2Ffullfact.m;fp=octave_packages%2Fstatistics-1.1.3%2Ffullfact.m;h=31ed007544576ede9e38aaa7b6ad95fb841d7228;hp=0000000000000000000000000000000000000000;hb=c880e8788dfc484bf23ce13fa2787f2c6bca4863;hpb=1705066eceaaea976f010f669ce8e972f3734b05 diff --git a/octave_packages/statistics-1.1.3/fullfact.m b/octave_packages/statistics-1.1.3/fullfact.m new file mode 100644 index 0000000..31ed007 --- /dev/null +++ b/octave_packages/statistics-1.1.3/fullfact.m @@ -0,0 +1,27 @@ +## Author: Paul Kienzle +## This program is granted to the public domain. + +## -*- texinfo -*- +## @deftypefn {Function File} fullfact (@var{N}) +## Full factorial design. +## +## If @var{N} is a scalar, return the full factorial design with @var{N} binary +## choices, 0 and 1. +## +## If @var{N} is a vector, return the full factorial design with choices 1 +## through @var{n_i} for each factor @var{i}. +## +## @end deftypefn + +function A = fullfact(n) + if length(n) == 1 + % combinatorial design with n either/or choices + A = fullfact(2*ones(1,n))-1; + else + % combinatorial design with n(i) choices per level + A = [1:n(end)]'; + for i=length(n)-1:-1:1 + A = [kron([1:n(i)]',ones(rows(A),1)), repmat(A,n(i),1)]; + end + end +endfunction