how to change the scale on the y-axis to a double log sclae?

조회 수: 8 (최근 30일)
Paraic Hickey
Paraic Hickey 2014년 4월 2일
편집: Vaibhav 2024년 2월 12일
Hi, I am plotting a CDF distribution for the max moment caused on a bridge by traffic. I want to change the scale on the y-axis to a double log or Gumbell scale. ie. Ln(Ln)(p) The default options for axis scale are only linear or log.
The code i am using is;
z= bootstrp(2500,@max,data);
cdfplot(z)
This returns a cdf plot of the data but I cannot change the value of the y-axis to a double log scale.What process do I need to use to achieve this double log scale?

답변 (2개)

dpb
dpb 2014년 4월 2일
편집: dpb 2014년 4월 2일
You'll have to do it manually by transforming the data and the y axis values then set the tick mark values at the appropriate tick marks based on the unscaled value location.
y=log(log(p)); % the data transformed
plot(x,y) % plotted on linear scale
xlim([log(log(ymin)) log(log(ymax))]) % set a y-axis limit in scaled units
yt = [ymin:ystep:ymax]; % a set of tick mark values
set(gca,'ytick',log(log(yt}},'yticklabel',num2str(yt.')); % set ticks/label same
NB: aircode, untested--salt to suit...

Vaibhav
Vaibhav 2024년 2월 12일
편집: Vaibhav 2024년 2월 12일
Hi Chencho
The Gumbel scale for the y-axis involves transforming the cumulative probabilities p to Ln(-Ln(1-p)).
Here's an approach to achieve this:
  1. Calculate the empirical CDF using the ecdf function instead of cdfplot.
  2. Transform the y-axis data to the Gumbel scale.
  3. Plot the transformed data.
Here's a code snippet for your reference:
% Bootstrap to get the maximum moments from the data
z = bootstrp(2500, @max, data);
% Calculate the empirical CDF
[F, x] = ecdf(z);
% Transform the y-axis data to Gumbel scale: Ln(-Ln(1-p))
% We need to avoid log(0) which occurs when p=1, so we limit p to be less than 1.
p = F(F < 1);
y_gumbel = log(-log(1 - p));
% Plot the transformed CDF data
plot(x(F < 1), y_gumbel);
xlabel('Max Moment');
ylabel('Ln(-Ln(1-p))');
title('CDF with Gumbel Scale for Y-axis');
% Optionally, you can add grid lines to help read the values
grid on;
You can refer to the MathWorks documentation below to learn more about "ecdf" function:
Hope this helps!

카테고리

Help CenterFile Exchange에서 Exploration and Visualization에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by