function [p] = pdf_rb(x,a,b)

%log pdf of a beta dist, rescaled to (-1,1)

if ~isequal(length(a),length(b))
    error('Parameters must be of equyal lengths')
end
lx=length(x);
x=reshape(x,[],1);
if length(a)==1
    a=a*ones(lx,1);
    b=b*ones(lx,1);
end
a=reshape(a,[],1); b=reshape(b,[],1);
p= (1-a-b)*log(2) - betaln(a,b) + (a-1).*log(1+x) + (b-1).*log(1-x);