]> Creatis software - CreaPhase.git/blobdiff - octave_packages/statistics-1.1.3/gamlike.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / statistics-1.1.3 / gamlike.m
diff --git a/octave_packages/statistics-1.1.3/gamlike.m b/octave_packages/statistics-1.1.3/gamlike.m
new file mode 100644 (file)
index 0000000..7085896
--- /dev/null
@@ -0,0 +1,21 @@
+## Author: Martijn van Oosterhout <kleptog@svana.org>
+## This program is granted to the public domain.
+
+## -*- texinfo -*-
+## @deftypefn {Function File} {@var{X} =} gamlike ([@var{A} @var{B}], @var{R})
+## Calculates the negative log-likelihood function for the Gamma
+## distribution over vector @var{R}, with the given parameters @var{A} and @var{B}.
+## @seealso{gampdf, gaminv, gamrnd, gamfit}
+## @end deftypefn
+
+function res = gamlike(P,K)
+
+  if (nargin != 2)
+    print_usage;
+  endif
+
+  a=P(1);
+  b=P(2);
+
+  res = -sum( log( gampdf(K, a, b) ) );
+endfunction