필터 지우기
필터 지우기

extension of symbols or probabilities

조회 수: 2 (최근 30일)
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
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