Hello,
Thanks! Updated 'corr2cov.m' as attached. Does it look better for the
financial package? And how to add new function to an existing package?
Best regards,
Hong Yu
>
> Looks good. I think you should do something to ensure that sigma is
> either a row or a column vector. You could add something like
>
> sigma = sigma (:);
>
> after the dimensionality tests.
>
> Søren
>
## Copyright (C) 2011 Hong Yu
##
## 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 3 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; see the file COPYING. If not, see
## <http://www.gnu.org/licenses/>.
## -*- texinfo -*-
## @deftypefn {Function File} {} corr2cov (@var{sigma}, @var{corr})
## Returns the covariance value or matrix.
##
##
## Note that the rate @var{r} is specified as a fraction (i.e., 0.05,
## not 5 percent).
## @seealso{corrcoef, cov, cov2corr, ewstats, std}
## @end deftypefn
## Author: Hong Yu <hyu0...@hotmail.com>
## Description: Convert standard deviation and correlation to covariance
function ret = corr2cov (sigma, corr)
if ( nargin != 2 )
print_usage ();
endif
ssize = size(sigma);
csize = size(corr);
if ( csize(1) != csize(2) )
error("sigma: must be 1xn \ncorr: must be nxn");
elseif ( ssize(1) != 1 )
error("sigma: must be 1xn \ncorr: must be nxn");
elseif ( ssize(2) < csize(1) )
error("sigma: must be 1xn \ncorr: must be nxn");
endif
sigma = sigma(:);
ret = corr .* (sigma * sigma');
endfunction
------------------------------------------------------------------------------
Doing More with Less: The Next Generation Virtual Desktop
What are the key obstacles that have prevented many mid-market businesses
from deploying virtual desktops? How do next-generation virtual desktops
provide companies an easier-to-deploy, easier-to-manage and more affordable
virtual desktop model.http://www.accelacomm.com/jaw/sfnl/114/51426474/
_______________________________________________
Octave-dev mailing list
Octave-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/octave-dev