Effacer les filtres
Effacer les filtres

extension of symbols or probabilities

2 vues (au cours des 30 derniers jours)
faraz.a
faraz.a le 2 Juin 2013
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 commentaires
faraz.a
faraz.a le 2 Juin 2013
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 le 2 Juin 2013
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?

Connectez-vous pour commenter.

Réponses (4)

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

Walter Roberson
Walter Roberson le 2 Juin 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 commentaire
Walter Roberson
Walter Roberson le 2 Juin 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)

Connectez-vous pour commenter.


Azzi Abdelmalek
Azzi Abdelmalek le 2 Juin 2013
Modifié(e) : Azzi Abdelmalek le 2 Juin 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 commentaires
Azzi Abdelmalek
Azzi Abdelmalek le 2 Juin 2013
Modifié(e) : Azzi Abdelmalek le 2 Juin 2013
No, I can not find the name in english, in french it's arrangement
Walter Roberson
Walter Roberson le 3 Juin 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.

Connectez-vous pour commenter.


Image Analyst
Image Analyst le 2 Juin 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 commentaires
Matt J
Matt J le 2 Juin 2013
That's a duplicate of my answer ( but I think you're right;) )
Image Analyst
Image Analyst le 3 Juin 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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by