extension of symbols or probabilities

1 次查看(过去 30 天)
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 个评论
faraz.a
faraz.a 2013-6-2
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
so 1-AA=0.3*0.3
2-AB= 0.3*0.25
3-AC=0.3*0.20
4-AD-0.3*0.10
5-AE
6-AF
7-AG
8-AH
9-BA
10-BB
11-BC
12-BD
...... son on till HH
same goes for 8 to 512
8^3=512
so 1-AAA
2-AAB
like wise till end HHH
faraz.a
faraz.a 2013-6-2
it is very long i can't just find the probabilities and give it as input.. i want to do this calculation in matlab. i want to extend those 8 probabilities to 64 like i showed you in the above comment how to do that?

请先登录,再进行评论。

回答(4 个)

Matt J
Matt J 2013-6-2
p64 = reshape(p.'*p,1,64);

Walter Roberson
Walter Roberson 2013-6-2
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 个评论
Walter Roberson
Walter Roberson 2013-6-2
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
Azzi Abdelmalek 2013-6-2
编辑:Azzi Abdelmalek 2013-6-2
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 个评论
Azzi Abdelmalek
Azzi Abdelmalek 2013-6-2
编辑:Azzi Abdelmalek 2013-6-2
No, I can not find the name in english, in french it's arrangement
Walter Roberson
Walter Roberson 2013-6-3
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
Image Analyst 2013-6-2
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 个评论
Matt J
Matt J 2013-6-2
That's a duplicate of my answer ( but I think you're right;) )
Image Analyst
Image Analyst 2013-6-3
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by