extension of symbols or probabilities
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
i am having this p=[ 0.3,0.25, 0.20, 0.10, 0.05, 0.04, 0.04, .02]; these are 8 symbols suppose A,B,C,D,E,F,G,H
now i want to extend these from 8 to 64
how to do that? using these above probabilities
4 comentarios
Respuestas (4)
Walter Roberson
el 2 de Jun. de 2013
My guess at what you want is
oldx = linspace(0,1,8);
newx = linspace(0,1,64);
newp = interp1(oldx, p, newx);
plot(oldx, p, 'b.', newx, newp, 'g')
The new entries will be linear interpolations of the old ones. You might prefer to use a non-linear interpolation.
1 comentario
Walter Roberson
el 2 de Jun. de 2013
ndim = 3; %8 to the how many?
[t{1:ndim}] = ndgrid(p);
newp = prod(cat(ndim+1, t{:}), ndim+1);
The answers are now in the n-dimensional matrix newp; e.g., BDH is newp(2,4,8)
Azzi Abdelmalek
el 2 de Jun. de 2013
Editada: Azzi Abdelmalek
el 2 de Jun. de 2013
s='A':'H'
p=[ 0.3,0.25, 0.20, 0.10, 0.05, 0.04, 0.04, .02]
idx=arrangement(1:8,2)
new_s=s(idx)
new_p=prod(p(idx),2)
out=[cellstr(new_s) num2cell(new_p)]
%-----------------------------------------------------------------
function y=arrangement(v,n)
m=length(v);
y=zeros(m^n,n);
for k = 1:n
y(:,k) = repmat(reshape(repmat(v,m^(n-k),1),m*m^(n-k),1),m^(k-1),1);
end
5 comentarios
Walter Roberson
el 3 de Jun. de 2013
The A[sub n][super k] given in that article is the same as the P(n,k) in Permutations, and your formula looks to me like the probability mass function of the Multinomial Distribution
I haven't worked through to see if your formula is correct. Even if it is, I would think that the version I gave in my answer (starting with "ndim = 3" is a lot easier to understand. Yours might require a factor of ndim less memory, though.
Image Analyst
el 2 de Jun. de 2013
My guess at what he wants:
probabilityTable = p' * p
probabilityTable =
0.09 0.075 0.06 0.03 0.015 0.012 0.012 0.006
0.075 0.0625 0.05 0.025 0.0125 0.01 0.01 0.005
0.06 0.05 0.04 0.02 0.01 0.008 0.008 0.004
0.03 0.025 0.02 0.01 0.005 0.004 0.004 0.002
0.015 0.0125 0.01 0.005 0.0025 0.002 0.002 0.001
0.012 0.01 0.008 0.004 0.002 0.0016 0.0016 0.0008
0.012 0.01 0.008 0.004 0.002 0.0016 0.0016 0.0008
0.006 0.005 0.004 0.002 0.001 0.0008 0.0008 0.0004
It's a 2D table of the probability of that pair, so you just enter in the two letters as indexes. For example, probabilityTable(1,1) = 0.03 * 0.03 = 0.009 just like he wanted. Of course you could convert to a 1D table if you wanted:
probabilityTable = probabilityTable(:);
2 comentarios
Image Analyst
el 3 de Jun. de 2013
You're right. I didn't notice at first because I saw the reshape(). I actually think it's more convenient to use the 2D version than the 1D version which he requested.
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!