How to calculate Krawchouk polynomials

8 views (last 30 days)
jenny jenny
jenny jenny on 8 Feb 2016
Commented: jenny jenny on 9 Feb 2016
This code Calculate the polynomials of Krawchouk but when I buildt the image that dosen't work help :
function [ Kw ] = polyK(N,p)%weighted Krawtchouk
%POLYK Summary of this function goes here
% Detailed explanation goes here
Kw=zeros(N,N);
w(1)= exp(N*log(1-p)) ;%the weight fuction for x=0
for x=1:1:N-1
w(x+1)=((N-x)/(x+1))*((p/(1-p)))*w(x);
end
for n=2:1:N-1
A=sqrt(((1-p)*(n+1))/(p*(N-n)));
B=sqrt(((1-p)*(1-p)*(n+1)*n)/(p*p*(N-n)*(N-n+1)));
for x=1:x:N
Kw(1,x) =sqrt(w(x));
Kw(2,x)=(1-(x/(p*N)))*sqrt(w(x));
Kw(n+1,x)=((A*((N*p)-(2*n*p)+n-x)*Kw(n,x))-(B*n*(1-p)*Kw(n-1,x)))/(p*(n-N));
end
end
end

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!