f

#### What does this matlab code do?

```Hello,

I have had the dubious distinction of inheriting tons of matlab code
from a former student (and he is gone, of course) and am trying to
figure out what it is doing. There is a particular code segment that
has me stumped and I was wondering if someone can help me figure out
what it actually does:

So, I have an array P that holds the joint PDF for 2 random variables.

So, the statement is:

a = 1 - cumsum(P,1)./repmat(sum(P,1),[number_of_hist_bins 1]);

number_of_hist_bins is the number of bins of the joint histogram in
any given dimension.

So, the 1-cumsum(P, 1) is somehow maybe the reliability/survival
function. So if P is a joint PDF then summing along the dimensions
would give the marginal PDFs and cumulative summing would give the CDF
and 1-CDF is the survival function from what I could find on
wikipedia.

However, I have no idea what the division by repmat(sum(P,1),
[number_of_hist_bins 1]) is doing... I have a feeling that this is
some sort of marginalisation but I cannot convince myself. sum(P, 1)
is the marginal PDF, so there is a normalisation of the CDF with the
PDF going on but I cannot fathom to what end...

I was wondering if anyone here has seen this sort of thing before and
maybe it some standard definition that I might have missed. I would be
really grateful if someone can help me figure it out...

Many thanks,
Anja
``` 0 2/23/2012 10:51:37 PM comp.soft-sys.matlab  211264 articles. 25 followers. 4 Replies 915 Views Similar Articles

[PageSpeed] 10

```"anja.ende@googlemail.com" <anja.ende@googlemail.com> wrote in message <7dc43dab-b78e-44a7-855b-4a13ea536393@db5g2000vbb.googlegroups.com>...
> Hello,
>
> I have had the dubious distinction of inheriting tons of matlab code
> from a former student (and he is gone, of course) and am trying to
> figure out what it is doing. There is a particular code segment that
> has me stumped and I was wondering if someone can help me figure out
> what it actually does:
>
> So, I have an array P that holds the joint PDF for 2 random variables.
>
> So, the statement is:
>
> a = 1 - cumsum(P,1)./repmat(sum(P,1),[number_of_hist_bins 1]);
>
> number_of_hist_bins is the number of bins of the joint histogram in
> any given dimension.
>
> So, the 1-cumsum(P, 1) is somehow maybe the reliability/survival
> function. So if P is a joint PDF then summing along the dimensions
> would give the marginal PDFs and cumulative summing would give the CDF
> and 1-CDF is the survival function from what I could find on
> wikipedia.
>
> However, I have no idea what the division by repmat(sum(P,1),
> [number_of_hist_bins 1]) is doing... I have a feeling that this is
> some sort of marginalisation but I cannot convince myself. sum(P, 1)
> is the marginal PDF, so there is a normalisation of the CDF with the
> PDF going on but I cannot fathom to what end...

It would give you a conditional PMF wouldn't it?

Also, have you checked that, at this stage in the code, that P is a properly normalized joint distribution, i.e. that sum(P(:))=1?

Incidentally, the use of REPMAT is inefficient if you have any version of MATLAB later than 2008. You could be doing,

1 - bsxfun(@rdivide, cumsum(P,1), sum(P,1));
``` 0 2/23/2012 11:47:36 PM
```"anja.ende@googlemail.com" <anja.ende@googlemail.com> wrote in message <7dc43dab-b78e-44a7-855b-4a13ea536393@db5g2000vbb.googlegroups.com>...
> Hello,
>
> I have had the dubious distinction of inheriting tons of matlab code
> from a former student (and he is gone, of course) and am trying to
> figure out what it is doing. There is a particular code segment that
> has me stumped and I was wondering if someone can help me figure out
> what it actually does:
>
> So, I have an array P that holds the joint PDF for 2 random variables.
>
> So, the statement is:
>
> a = 1 - cumsum(P,1)./repmat(sum(P,1),[number_of_hist_bins 1]);
>
> number_of_hist_bins is the number of bins of the joint histogram in
> any given dimension.
>
> So, the 1-cumsum(P, 1) is somehow maybe the reliability/survival
> function. So if P is a joint PDF then summing along the dimensions
> would give the marginal PDFs and cumulative summing would give the CDF
> and 1-CDF is the survival function from what I could find on
> wikipedia.
>
> However, I have no idea what the division by repmat(sum(P,1),
> [number_of_hist_bins 1]) is doing... I have a feeling that this is
> some sort of marginalisation but I cannot convince myself. sum(P, 1)
> is the marginal PDF, so there is a normalisation of the CDF with the
> PDF going on but I cannot fathom to what end...
>
> I was wondering if anyone here has seen this sort of thing before and
> maybe it some standard definition that I might have missed. I would be
> really grateful if someone can help me figure it out...

To elaborate a bit on my last post, the code you've shown would be equivalent to

C=P./repmat(sum(P,1),[number_of_hist_bins 1]); %conditional PMF

b=cumsum(C,1); %conditional CDF

a = 1 - b;  %conditional "survival function"
``` 0 2/23/2012 11:51:28 PM
```On Feb 23, 5:51=A0pm, "anja.e...@googlemail.com"
> Hello,
>
> I have had the dubious distinction of inheriting tons of matlab code
> from a former student (and he is gone, of course) and am trying to
> figure out what it is doing. There is a particular code segment that
> has me stumped and I was wondering if someone can help me figure out
> what it actually does:
>
> So, I have an array P that holds the joint PDF for 2 random variables.
>
> So, the statement is:
>
> a =3D 1 - cumsum(P,1)./repmat(sum(P,1),[number_of_hist_bins 1]);
>
> number_of_hist_bins is the number of bins of the joint histogram in
> any given dimension.
>
> So, the 1-cumsum(P, 1) is somehow maybe the reliability/survival
> function. So if P is a joint PDF then summing along the dimensions
> would give the marginal PDFs and cumulative summing would give the CDF
> and 1-CDF is the survival function from what I could find on
> wikipedia.
>
> However, I have no idea what the division by repmat(sum(P,1),
> [number_of_hist_bins 1]) is doing... I have a feeling that this is
> some sort of marginalisation but I cannot convince myself. sum(P, 1)
> is the marginal PDF, so there is a normalisation of the CDF with the
> PDF going on but I cannot fathom to what end...
>
> I was wondering if anyone here has seen this sort of thing before and
> maybe it some standard definition that I might have missed. I would be
> really grateful if someone can help me figure it out...
>
> Many thanks,
> Anja

a =3D 1 - cumsum(P,1)./repmat(sum(P,1),[number_of_hist_bins 1]);
a =3D 1 - cumsum(P,1)./repmat(sum(P,1),[size(P,1) 1]);
a =3D 1 - cumsum(P)./repmat(sum(P),[size(P,1) 1]);

Notice that all operations are columnwise. Therefore,  each column
refers to a marginal distribution,

For 1-D: if P is a histogram

a=3D 1 - cumsum(P)/sum(P)
a =3D 1 - CDF

Therefore, the denominator is needed to scale the CDF to [0,1].

For multiple dimensions, each column is independent of the others.
Consequently, multiplying each column of P by a different arbitrary
constant will not affect the result.

Hope this helps.

Greg
``` 0 2/24/2012 6:40:00 AM
```Thank you Matt and Greg. That clears everything a lot!

Anja
``` 0 2/26/2012 11:45:25 AM Similar Artilces:

some problems of codes of MATLAB 7.0 working on MATLAB 6.5
I have used MATLAB for few hours.So I don't know the differences between version 6.5 and 7.0.I want to use some codes of MATLAB 7.0, but they doesn't work in MATLAB 6.5.How to change these codes so that they can work in matlab 6.5.Waiting for your help. Thank you . The codes are like this .I think changing the function findPI may work ,but I don'y know how % PIfun.m % Evaluate a function used to find the PI-line, using Kyle Champley's % method. % % Adam Wunderlich % last update: 5/18/06 function y = PIfun(r,R,h,gamma,x3,sb) temp = R - r*cos(gamma-sb); y = h*((pi - 2*atan(r*sin(gamma-sb)/temp))*(1 + (r^2 - R^2)/ (2*R*temp)) ... + sb) - x3; % find_PI_Line.m % % Find the the parametric interval corresponding to the unique PI-line % passing through the point x for a given helical pitch. % This code implements the method of Kyle Champley. % inputs: P = pitch (cm/turn), R = helix radius, delta_s = s stepsize, x % output: PI = [sb st] % % Adam Wunderlich % last update: 5/18/06 function [PI] = findPI(P,R,delta_s,x) h = P/(2*pi); r = sqrt(x(1)^2+x(2)^2); gamma = atan2(x(2),x(1)); options = optimset('TolX',h*delta_s/100,'FunValCheck','on'); [sb,fval,exitflag] = fzero(@(sb) PIfun(r,R,h,gamma,x(3),sb),... [(x(3)-h*pi)/h,x(3)/h],options); if exitflag ~=1, disp('Error: PI invalid'); end % note that beta=sb in Kyle's formula alphaX = atan(r*sin(gamma-sb)/(R - r*cos(gamma-sb))); st = sb + pi -...

Trellis code in matlab code
Hi All Do you have some matlab code for the STTC which will give me some Idea. Any helping material or URL regarding the same will kindly be sent to me. I shall be very thankful to you for this act. Regards Kelecha ...

Matlab engine with matlab R2010b
Hello All, I'm working with an aplication that use the matlab engine. I made the C++ program and it is working well in my pc with matlab 2007b, but the same very basic program shows an error when I tried to compile it in a pc with matlab R2010b. The error is about the icuuc32.dll. ¿Why is asking this DLL? How can I solve this?. Thanks¡ ...

converting matlab code to C code
when i tried to convert the matlab code into c code using matlab coder i got below mentioned error, I am using R2011b(7.13.0.534) my program uses image as an input parameter. ERROR: >> coder -build len.prj ??? This text contains non-empty top-level expressions. It appears to be a script. Error in ==> length_of_line Line: 1 Column: 1 Code generation failed: Open error report. CODE: I=imread('pic29rkey.jpg'); imshow(I);pause hold on [x,y] = ginput(2); line(x,y,'color','r','LineWidth',5); Ired_length = sqrt ((x(2)-x(1))^2 + (y(2)-y(1))^2); [x,y] = ginput(2); line(x,y,'color','g','LineWidth',5); lineLength = sqrt ((x(2)-x(1))^2 + (y(2)-y(1))^2); Igreen_length= lineLength/Ired_length*10; disp(Igreen_length); msgbox(sprintf('Length of the Key is %f cm',Igreen_length)); How to solve this issue? this is the first time i am using this code conversiuon tool thats why! Thanks in advance... "arunkumar " <arun.pk2k3@gmail.com> wrote in message news:jnm1kd\$pog\$1@newscl01ah.mathworks.com... > when i tried to convert the matlab code into c code using matlab coder i > got below mentioned error, I am using R2011b(7.13.0.534) my program uses > image as an input parameter. > > ERROR: >>> coder -build len.prj ??? This text contains non-empty top-level >>> expressions. It appears to be a script. Error in ==> length_of_line >>> Lin...

how to convert Matlab code to C code
Hi everyone, Can any one tell me how to convert matlab to c?? Regards. On 5/8/2012 4:36 PM, WMS wrote: > Hi everyone, > Can any one tell me how to convert matlab to c?? > > Regards. http://www.mathworks.com/products/matlab-coder/ "MATLAB Coder™ generates standalone C and C++ code from MATLAB code" ...

Shall i use the misrosoft Visual c++ code from a m-file generated from matlab in Visual C++ with out matlab runtime environment
undefined ...

soft decoding of conv. codes using vitdec matlab func. #2
Hello, Isnt 'unquant' and 'soft' options essentially same?..in both case vitdec takes in "real numbers" as input (ok they are "mapped" in case o 'soft' option)..so can we not use 'unquant' option to carry out sof decoding?...my preliminary results show that 'unquant' option give me 2- db gain over hard decoding... any one having insight please let me know. thanks >Hello, > Isnt 'unquant' and 'soft' options essentially same?..in both cases >vitdec takes in "real numbers" as input (ok they are "mapped" in case of >'soft' option)..so can we not use 'unquant' option to carry out soft >decoding?...my preliminary results show that 'unquant' option give m 2-3 >db gain over hard decoding... >any one having insight please let me know. >thanks > > %%% Yes , u can use 'unquant' as soft decoding. try to implement for k=3 i.e [5 7] and BPSK and at roughly 4 dB u should get BER of 10^-3. Chintan ...

MATLAB Code for simualting the spreading using Walsh Codes

matlab source code of MAP decoder for block codes to share?
Hi, I need to run some simulations results of MAP decoding of BLOCK codes. Has anyone has source code(matlab) of such MAP decoder for block codes t share? Or can someone kindly provide me information on where I can ge such source code? Your help is greatly appreciated. Thanks a lot! kc This message was sent using the Comp.DSP web interface o www.DSPRelated.com kc <lkc_pringles@hotmail.com> wrote: >I need to run some simulations results of MAP decoding of BLOCK codes. >Has anyone has source code(matlab) of such MAP decoder for block codes to >share? Or can someone kindly provide me information on where I can get >such source code? > >Your help is greatly appreciated. I don't have the answer to your question, but I'm curious what sort of block codes you'd like to MAP-decode. It's practical for small Hamming codes. A few years back near-MAP decoding of Hamming constituent codes in a turbo code configuration was popular for awhile, so you could try searching for those implementations. Steve >kc <lkc_pringles@hotmail.com> wrote: > >>I need to run some simulations results of MAP decoding of BLOCK codes. >>Has anyone has source code(matlab) of such MAP decoder for block code to >>share? Or can someone kindly provide me information on where I can get >>such source code? >> >>Your help is greatly appreciated. > >I don't have the answer to your question, but I'm curious ...

matlab code for video coding format h.263 #2
HI , I M DOING MY M.TECH PROJECT ON H.263 .CAN ANYBOBY HELP ME WITH SOURCE CODE FOR IT USING EITHER DCT TRANSFORM OR WAVELET TRANSFORM. PLEASE REPLY IMMEDIATELY IF ANYBODY KNOWS. ITS URGENT. THANKS A LOT! ...

matlab code for video coding format h.263 #3
HI , I M DOING MY M.TECH PROJECT ON H.263 .CAN ANYBOBY HELP ME WITH SOURCE CODE FOR IT USING EITHER DCT TRANSFORM OR WAVELET TRANSFORM. PLEASE REPLY IMMEDIATELY IF ANYBODY KNOWS. ITS URGENT. THANKS A LOT! ...

Matlab parallel for loop or Matlab open pool
I am trying to to some computations and I would like to do it in parallel using parfor or by Opening the matlabpool.. as the current implementations is too slow: result=zeros(25,16000); for i = 1:length(vector1) % length is 25 for j = 1:length(vector2) % length is 16000 temp1 = vector1(i); temp2 = vector2(j); t1 = load(matfiles1(temp1).name) %load image1 from matfile1 t2 = load(matfiles2(temp2).name) % load image2 from matfile2 result(i,j)=t1.*t2 end end It work fine but I would really like to know if there is a way to speed thing up ... Thanks a lot in advance! ...

matlab code of aes
can anyone provide me with matlab code of aes "shalini" wrote in message <jmr6r3\$s5r\$1@newscl01ah.mathworks.com>... > can anyone provide me with matlab code of aes "shalini" wrote in message <jmr6r3\$s5r\$1@newscl01ah.mathworks.com>... > can anyone provide me with matlab code of aes Dear Shalini, I had published the function CryptAES in the FEX, but it has been removed, because it conflicts with the U.S. Export Administration Regulations governed by the U.S. Dept. of Commerce, Bureau of Industry and Security. This concerned all other AES implementations also. If you search in the net, you can still find it, because all FEX submissions are copied soon. Another tool, which uses a Java call from Matlab has been copied to this newgroup also. I had extremly tedious discussions about the risk resulting from a published program for AES encryption. The US government decided that it is a real risk, if somebody downloads the code from one of the 5 states belonging to the axis of evil. Anyhow, you can still download the detailed specifications as PDF from official sites in the US, because a PDF is covered be the freedom of speech. Even when you download Java, you have to confirm by clicking a checkbox, that you do not live in one of the evil countries. Then the 256-bit encryption is available, otherwise the key length is limited to 128 bits. Kind regards, Jan ...

Matlab code #45
I have my final year project on image steganography using lsb technique.I have done the embedding of least significant 4bits but i am unable to hide those pixel values which are same for both the images.I am using gray scale images.Please help ...

Matlab Code and help
Hi I need help on below...pls can some one give me the code I need to carry out these steps in Matlab.. Take an image in Raw in TIFF file...and then perform a) JPEG @ quality 100, 80, 60, 40, 20 and 0 b) SPIHT @ quality 100, 80, 60, 40, 20 and 0 c) EZW @ quality 100, 80, 60, 40, 20 and 0 Next step - Get MSE for all the above need to plot the graph.. Many Thanks "Indrasena " <mail2svijay@yahoo.com> wrote in message hello, may i know were you able to do this, becasue took me a while to do this code, need some clarificatiosn if you are done because i am done with SPIHT and EZW is left? what r u using the built in codes or the the matlab toolbox?? contact me at makeyourassignment@yahoo.com ...

how to code this equation in matlab
Can some one help me the right way of coding the following equation into MATLAB. I am having problems in coding this equation. y = [y0 + A* exp -(x.(x-xc)^2/2w^2)]. (1-exp-(b*x)) lene wrote: > Can some one help me the right way of coding the following equation into MATLAB. I am having problems in coding this equation. > y = [y0 + A* exp -(x.(x-xc)^2/2w^2)]. (1-exp-(b*x)) y = (y0 + A .* exp(-(x .* (x-xc) .^ 2 / (2 * w .^ 2))) .* (1-exp(-b .* x)) "lene" <shazia.naureen@gmail.com> wrote in message news:907898463.131520.1273780800933.JavaMail.root@gallium.mathforum.org... > Can some one help me the right way of coding the following equation into > MATLAB. I am having problems in coding this equation. > > y = [y0 + A* exp -(x.(x-xc)^2/2w^2)]. (1-exp-(b*x)) Certainly. Show us how you coded it and explain specifically what problems you're having (what error or warning do you receive, or what values do you receive that are different than the values you expect) and you should receive some help. -- Steve Lord slord@mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ ...

hello everyone. I m working on simulink based model for transient stability analysis of a multi-machine system. i have completely constructed the model using basic simulink blocks. But i m not able to include a program in the model to run the matlab model. I tried writing a program in a m-file and then executing the model still its not working. I get the same waveforms for all fault clearing time. Pls can anyone help ...

huffman coding matlab
anyone know about the compression image coding using matlab huffman? On Aug 5, 2:50=A0am, "rizqi " <rizqi.hendr...@gmail.com> wrote: > anyone know about the compression image coding using matlab huffman? yes, me ...

Matlab Code #46
Hi. I am new to this Matlab GUI and would love for your help. I have an m-file that runs perfectly to do detection tumor. But I face a problem which is it cannot do detection for the new image that browse from other file. In my m-file, I already set 12 different images in command slider, so when run the program it can do detection for each image in slider. But how can I make it also can do detection for the new image that had browse from file? I think maybe I need to add in the new image path to the slider command there. But I not really know the new image path in my code.. Any help and advice would be greatly appreciated. Elise ...

MATLAB code #43
please help me with the code for this paper. "Image Enhancement by wavelet based thresholding neural network with adaptive learning rate". I ll will you if you need. Urgent... On Mar 15, 5:11=A0am, "Dinesh " <dinesh11...@yahoo.com> wrote: > please help me with the code for this paper. "Image Enhancement by wavele= t based thresholding neural network with adaptive learning rate". I ll will= you if you need. Urgent... --------------------------------------------------- You will what? Pay someone as a consultant to code up the algorithm in the paper for you? ...

Matlab code #42
Hi I am looking for a matlab code on tabu search and simulated annealing. Can anyone help me to see if I can use the MATLAB for optimization by TS and SA? Thanks in adv for any assistance. "Lina " <linahanafi@hotmail.com> wrote in message news:jj473p\$iu6\$1@newscl01ah.mathworks.com... > Hi > I am looking for a matlab code on tabu search and simulated annealing. Can > anyone help me to see if I can use the MATLAB for optimization by TS and > SA? For simulated annealing, look at Global Optimization Toolbox. http://www.mathworks.com/products/global-optimization/ I don't see anything similar for tabu search in the documentation, but a Google search for "tabu search MATLAB" found many hits. Some of those probably contain code. -- Steve Lord slord@mathworks.com To contact Technical Support use the Contact Us link on http://www.mathworks.com Hi Steven. I found the optimization toolbox is great. Thanks for this information. "Steven_Lord" <slord@mathworks.com> wrote in message <jj7tmb\$8e\$1@newscl01ah.mathworks.com>... > > > "Lina " <linahanafi@hotmail.com> wrote in message > news:jj473p\$iu6\$1@newscl01ah.mathworks.com... > > Hi > > I am looking for a matlab code on tabu search and simulated annealing. Can > > anyone help me to see if I can use the MATLAB for optimization by TS and > > SA? > > For simulated annealing, look at Global Optim...

MATLAB Code #44
Hey i need to use MATLAB to input audio files like sounds and then compare them? Any idea how i can compare them and fine the percentage of error? Would anyone recommend the use of a spectogram? If so at what sampling frequency?? ...

Contribute to MATLAB Central and Win a MATLAB Jacket
Many of you who post to this newsgroup are also regular contributors to the MATLAB Central File Exchange. Look for your favorite contributors on our File Exchange Author Profile page. You can read their profiles and see pictures: <http://www.mathworks.com/matlabcentral/reports/fileexchange/allProfiles/> In a random drawing, we recently awarded MATLAB jackets to three File Exchange authors with profile pages: Michele Giugliano, Andrey Egin, and Denis Gilbert. You can win a jacket, too. Just submit a new file to the File Exchange or update your author profile by December 2003 for a chance to win one of four MATLAB jackets. See the jacket below: <http://www.mathworks.com/matlabcentral/images/jeff3.jpg> Here are some interesting File Exchange facts: - Since its inception in 2001, visitors have downloaded more than 1.25 million submissions from the File Exchange. - In September 2003 alone, visitors downloaded 80,085 files, an average of 2670 a day! .... what if the prize was a free copy of the next version of Matlab :-) majb Min Poh wrote: ....or an offer for employment... aj "bourassa" <bourassa-m@rmc.ca> wrote in message news:3f9d507d\$1@rmcnt03a.rmc.ca... > ... what if the prize was a free copy of the next version of Matlab :-) > > majb > > Min Poh wrote: > ...

request for code in matlab
how to code for an improved reversible data hiding in encrypted images using side match? ... Web resources about - What does this matlab code do? - comp.soft-sys.matlab Matlab Upazila - Wikipedia, the free encyclopedia
... 23°21′N 90°42.5′E ﻿ / ﻿ 23.35°N 90.7083°E ﻿ / 23.35; 90.7083 Coordinates : 23°21′N 90°42.5′E ﻿ / ﻿ 23.35°N 90.7083°E ﻿ / 23.35; 90.7083 Matlab ...

Open Directory - Science: Math: Software: MATLAB
The MathWorks - Developers of MATLAB, Simulink and Stateflow. Offers products for data analysis, visualization, application development, simulation, ... MATLAB Mobile on the App Store The Smart Emergency Response System Using MATLAB and Simulink - YouTube
In the aftermath of an earthquake, every second counts for disaster victims. Imagine a system that can locate people quickly and help first responders ...

Matlab: Invalid .NET Framework. Either the specified framework was not found or is not currently supported ...
If you are trying to compile Matlab into .Net framework, you might encounter this message, even though you have the .Net framework installed ...

Matlab edges closer to electronic design automation world
Matlab, one of the world's most widely used products for algorithmic development, has long occupied its own niche far removed from EDA and hardware ... Can I/How do I use DMTCP with a parallel pool of MATLAB workers? · Issue #223 · dmtcp/dmtcp · GitHub
dmtcp - DMTCP: Distributed MultiThreaded CheckPointing matlab -nodisplay -r "parpool('local',4); parfor i=1:10, pause(1); fprintf('%i ',i); end; ... Using MATLAB and SDR to Reverse Engineer 433MHz Messages
... so he focused on studying the methodology and the tools available for analyzing 433MHz RF transmission. He describes the process of using MATLAB ...

Resources last updated: 3/30/2016 2:05:21 PM