⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lmom.asv

📁 to caluculate the legendre polynomials
💻 ASV
字号:
% lmom by Kobus N. Bekker, 14-09-2004
% Based on calculation of probability weighted moments and the coefficient
% of the shifted Legendre polynomial.

% Given nonnegative integer nL, compute the 
% nL l-moments for given data vector X. 
% Return the l-moments as vector L.

function [L] = lmom(X,nL)

[rows cols] = size(X);
if cols == 1 X = X'; end
n = length(X);
X = sort(X);
b = zeros(1,nL-1);
l = zeros(1,nL-1);
b0 = mean(X);
for r = 1:nL-1
    Num = prod(repmat(r+1:n,r,1)-repmat([1:r]',1,n-r),1);
    Den = prod(repmat(n,1,r) - [1:r]);
    b(r) = 1/n * sum((Num/Den) .* double(X(r+1:n)) );
end

tB = [b0(:,:,1) b(1)
      b0(:,:,2) b(2)
      b0(:,:,3) b(3)]';
      %tB=[b0 b]';
B = tB(length(tB):-1:1);

for j = 1:nL-1
    Spc = zeros(length(B)-(j+1),1);
    Coeff = [Spc ; LegendreShiftPoly(j)];
    %coeff=transpose(Coeff);
   
    l= sum(Coeff*B,1);
    m(:,:,j)=l;
end

L = [b0(:,:,1) b(1)
      b0(:,:,2) b(2)
      b0(:,:,3) b(3)];

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -