how to make a pdf(probability density function) plot from a cdf(cumulative distributive function) plot?
    조회 수: 30 (최근 30일)
  
       이전 댓글 표시
    
I have a CDF data and plot: my vector is 'on'
            CDF_on = ecdf(on);
            figure
            ecdf(on)
i would like to get a pdf plot from this. i know that pdf values are derivative of cdf values. I try to do this way:
            PDF_on=diff(CDF_on);
            figure
            plot(PDF_on,'-*')
derivative is good I think, but there is something wrong with x axis. My values on PDF plot are supposed to match the values on CDF plot but they dont. Please help? Thanks guys
댓글 수: 0
답변 (1개)
  Star Strider
      
      
 2014년 4월 9일
        
      편집: Star Strider
      
      
 2014년 4월 9일
  
      Try this:
PDF_on=diff([0 CDF_on]);    % CDF_on is a row vector
or
PDF_on=diff([0; CDF_on]);   % CDF_on is a column vector
Padding with the initial zero preserves the first element and makes the array sizes of PDF_on and CDF_on equal.
EDIT -- If you want PDF_on as d( CDF_on ) / d(x), do the same diff operation on the x vector, then do an element-by-element divide:
dfdx = diff([0 f]) ./ diff([0 x]);
댓글 수: 0
참고 항목
카테고리
				Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

