Changeset 1013


Ignore:
Timestamp:
06/15/09 15:07:31 (16 years ago)
Author:
jschierm
Message:

More documentation and copyrights.

Location:
issm/trunk/src/m/solutions/dakota
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/m/solutions/dakota/plot_boxplot.m

    r1 r1013  
    11%
    2 %  plot a box plot of the response functions.
     2%  plot a box plot of the responses.
    33%
    4 %  []=plot_boxplot(rfunc)
     4%  []=plot_boxplot(dresp)
    55%
    6 function []=plot_boxplot(rfunc)
     6%  where the required input is:
     7%    dresp         (structure array, responses)
     8%
     9%  the required fields of dresp are:
     10%    descriptor    (char, description)
     11%    sample        (double vector, list of samples)
     12%
     13%  for each response in the input array, this functionplots a
     14%  matlab box plot of the list of samples and annotates it
     15%  with the description.  the lists of samples need not all be
     16%  the same length.
     17%
     18%  this data would typically be contained in the dakota tabular
     19%  output file and read by dakota_out_parse.
     20%
     21%  "Copyright 2009, by the California Institute of Technology.
     22%  ALL RIGHTS RESERVED. United States Government Sponsorship
     23%  acknowledged. Any commercial use must be negotiated with
     24%  the Office of Technology Transfer at the California Institute
     25%  of Technology.  (NTR 47078)
     26%
     27%  This software may be subject to U.S. export control laws.
     28%  By accepting this  software, the user agrees to comply with
     29%  all applicable U.S. export laws and regulations. User has the
     30%  responsibility to obtain export licenses, or other export
     31%  authority as may be required before exporting such information
     32%  to foreign countries or providing access to foreign persons."
     33%
     34function []=plot_boxplot(dresp)
    735
    836if ~nargin
     
    1341%%  assemble the data into a matrix
    1442
    15 desc=cell (1,length(rfunc));
    16 for i=1:length(rfunc)
    17     ldata(i)=length(rfunc(i).sample);
     43desc=cell (1,length(dresp));
     44for i=1:length(dresp)
     45    ldata(i)=length(dresp(i).sample);
    1846end
    19 data=zeros(max(ldata),length(rfunc));
     47data=zeros(max(ldata),length(dresp));
    2048
    21 for i=1:length(rfunc)
    22     desc(i)=cellstr(rfunc(i).descriptor);
    23     data(1:ldata(i),i)=rfunc(i).sample;
     49for i=1:length(dresp)
     50    desc(i)=cellstr(dresp(i).descriptor);
     51    data(1:ldata(i),i)=dresp(i).sample;
    2452end
    2553
     
    3361%  add the annotation
    3462
    35 title('Box Plot of Design Variables and/or Response Functions')
    36 xlabel('Design Variable or Response Function')
     63title('Box Plot of Variables and/or Responses')
     64xlabel('Variable or Response')
    3765ylabel('Value')
    3866
  • issm/trunk/src/m/solutions/dakota/plot_hist_norm.m

    r1 r1013  
    11%
    2 %  plot a relative histogram along with the normal distribution.
    3 %
    4 %  []=plot_hist_norm(rfunc1   ,rfunc2  ,hmin,hmax,hnint)
    5 %  []=plot_hist_norm(data,desc,mu,sigma,hmin,hmax,hnint)
     2%  plot a relative histogram and cdf optionally along with
     3%  a normal distribution.
     4%
     5%  []=plot_hist_norm(dresp1   ,dresp2  ,hmin,hmax,hnint)
     6%  []=plot_hist_norm(samp,desc,mu,sigma,hmin,hmax,hnint)
     7%
     8%  where the required varargin is:
     9%    dresp1        (structure array, responses)
     10%      or
     11%    samp          (double array, lists of samples)
     12%    desc          (cell array, list of descriptions)
     13%
     14%  and the optional input is:
     15%    dresp2        (structure array, responses)
     16%      or
     17%    mu            (double vector, means)
     18%    sigma         (double vector, standard deviations)
     19%
     20%    hmin          (numeric, minimum for histogram)
     21%    hmax          (numeric, maximum for histogram)
     22%    hnint         (numeric, number of intervals for histogram)
     23%
     24%  the required fields of dresp1 are:
     25%    descriptor    (char, description)
     26%    sample        (double vector, list of samples)
     27%
     28%  and the required fields of dresp2 are:
     29%    mean          (double, mean of sample)
     30%    stddev        (double, standard deviation of sample)
     31%
     32%  for each response in the input array, this function
     33%  calculates and plots a relative histogram and CDF of the list
     34%  of samples, and annotates it with the description.  in
     35%  addition, a mean and standard deviation may be supplied or
     36%  calculated so that a normal distribution and CDF may be
     37%  plotted.
     38%
     39%  dresp1 data would typically be contained in the dakota tabular
     40%  output file from a sampling analysis, and dresp2 data would
     41%  typically be contained in the dakota output file from a local
     42%  sensitivity analysis, both read by dakota_out_parse.
     43%
     44%  "Copyright 2009, by the California Institute of Technology.
     45%  ALL RIGHTS RESERVED. United States Government Sponsorship
     46%  acknowledged. Any commercial use must be negotiated with
     47%  the Office of Technology Transfer at the California Institute
     48%  of Technology.  (NTR 47078)
     49%
     50%  This software may be subject to U.S. export control laws.
     51%  By accepting this  software, the user agrees to comply with
     52%  all applicable U.S. export laws and regulations. User has the
     53%  responsibility to obtain export licenses, or other export
     54%  authority as may be required before exporting such information
     55%  to foreign countries or providing access to foreign persons."
    656%
    757function []=plot_hist_norm(varargin)
     
    1666ivar=1;
    1767if isstruct(varargin{ivar})
    18     rfunc1=varargin{ivar};
     68    dresp1=varargin{ivar};
    1969    ivar=ivar+1;
    2070   
    21     desc=cell (1,length(rfunc1));
    22     ldata=zeros(1,length(rfunc1));
    23     for i=1:length(rfunc1)
    24         ldata(i)=length(rfunc1(i).sample);
    25     end
    26     data=zeros(max(ldata),length(rfunc1));
    27     data(:,:)=NaN;
    28 
    29     for i=1:length(rfunc1)
    30         desc(i)=cellstr(rfunc1(i).descriptor);
    31         data(1:ldata(i),i)=rfunc1(i).sample;
    32     end
    33 else
    34     data=varargin{ivar};
     71    desc=cell (1,length(dresp1));
     72    lsamp=zeros(1,length(dresp1));
     73    for i=1:length(dresp1)
     74        lsamp(i)=length(dresp1(i).sample);
     75    end
     76    samp=zeros(max(lsamp),length(dresp1));
     77    samp(:,:)=NaN;
     78
     79    for i=1:length(dresp1)
     80        desc(i)=cellstr(dresp1(i).descriptor);
     81        samp(1:lsamp(i),i)=dresp1(i).sample;
     82    end
     83else
     84    samp=varargin{ivar};
    3585    ivar=ivar+1;
    3686   
    37     ldata(1:size(data,2))=size(data,1);
     87    lsamp(1:size(samp,2))=size(samp,1);
    3888
    3989    if ivar <= nargin && iscell(varargin{ivar})
     
    4696
    4797if     ivar <= nargin && isstruct(varargin{ivar})
    48     rfunc2=varargin{ivar};
    49     ivar=ivar+1;
    50 
    51     mu   =zeros(1,length(rfunc2));
    52     sigma=zeros(1,length(rfunc2));
    53 
    54     for i=1:length(rfunc2)
    55         mu   (i)=rfunc2(i).mean;
    56         sigma(i)=rfunc2(i).stddev;
     98    dresp2=varargin{ivar};
     99    ivar=ivar+1;
     100
     101    mu   =zeros(1,length(dresp2));
     102    sigma=zeros(1,length(dresp2));
     103
     104    for i=1:length(dresp2)
     105        mu   (i)=dresp2(i).mean;
     106        sigma(i)=dresp2(i).stddev;
    57107    end
    58108elseif ivar+1 <= nargin
     
    61111            mu   =varargin{ivar};
    62112        else
    63             mu   =mean(data);
     113            mu   =mean(samp);
    64114            display('Using calculated means.')
    65115        end
     
    70120            sigma=varargin{ivar};
    71121        else
    72             sigma=std(data);
     122            sigma=std(samp);
    73123            display('Using calculated standard deviations.')
    74124        end
     
    82132    hmin=varargin{ivar};
    83133else
    84     hmin=min(min(data));
     134    hmin=min(min(samp));
    85135end
    86136ivar=ivar+1;
     
    88138    hmax=varargin{ivar};
    89139else
    90     hmax=max(max(data));
     140    hmax=max(max(samp));
    91141end
    92142ivar=ivar+1;
     
    107157%  Use -inf and inf in edges to include all non-NaN values.
    108158
    109 dhistc=histc(data,edges);
    110 for i=1:size(data,2)
    111     dbelow(i)  =length(find(data(:,i)<edges(  1)))/ldata(i);
    112     dhistc(:,i)=dhistc(:,i)                       /ldata(i);
    113     dabove(i)  =length(find(data(:,i)>edges(end)))/ldata(i);
     159dhistc=histc(samp,edges);
     160for i=1:size(samp,2)
     161    dbelow(i)  =length(find(samp(:,i)<edges(  1)))/lsamp(i);
     162    dhistc(:,i)=dhistc(:,i)                       /lsamp(i);
     163    dabove(i)  =length(find(samp(:,i)>edges(end)))/lsamp(i);
    114164end
    115165
    116166if exist('mu','var') && exist('sigma','var')
    117     ncol=size(data,2);
     167    ncol=size(samp,2);
    118168    for i=1:ncol
    119169        dbelow(ncol+i)=normcdf(edges(  1),mu(i),sigma(i));
  • issm/trunk/src/m/solutions/dakota/plot_if_bars.m

    r1 r1013  
    22%  plot a stacked bar chart of the importance factors.
    33%
    4 %  []=plot_if_bars(rfunc,ifmin,isort)
     4%  []=plot_if_bars(dresp,ifmin,isort)
    55%
    6 function []=plot_if_bars(rfunc,ifmin,isort)
     6%  where the required input is:
     7%    dresp         (structure array, responses)
     8%
     9%  and the optional input is:
     10%    ifmin         (double, minimum importance factor)
     11%    isort         (numeric, sort flag:  0, no sorting;
     12%                                        1, highest at bottom;
     13%                                       -1, lowest at bottom)
     14%
     15%  the required fields of dresp are:
     16%    descriptor    (char, description)
     17%    var           (cell array, variables)
     18%    impfac        (double array, importance factors)
     19%
     20%  for each response in the input array, this function plots
     21%  a stacked bar plot of the responses, where the bars are
     22%  stacked by the importance factors, and annotates it with the
     23%  description.  the legend labels are constructed from the
     24%  variable list.
     25%
     26%  this data would typically be contained in the dakota output
     27%  file from a local reliability analysis and read by
     28%  dakota_out_parse.
     29%
     30%  "Copyright 2009, by the California Institute of Technology.
     31%  ALL RIGHTS RESERVED. United States Government Sponsorship
     32%  acknowledged. Any commercial use must be negotiated with
     33%  the Office of Technology Transfer at the California Institute
     34%  of Technology.  (NTR 47078)
     35%
     36%  This software may be subject to U.S. export control laws.
     37%  By accepting this  software, the user agrees to comply with
     38%  all applicable U.S. export laws and regulations. User has the
     39%  responsibility to obtain export licenses, or other export
     40%  authority as may be required before exporting such information
     41%  to foreign countries or providing access to foreign persons."
     42%
     43function []=plot_if_bars(dresp,ifmin,isort)
    744
    845if ~nargin
     
    2158%%  assemble the data into a matrix
    2259
    23 desc=cell (1,length(rfunc));
    24 for i=1:length(rfunc)
    25     ldata(i)=length(rfunc(i).impfac);
     60desc=cell (1,length(dresp));
     61for i=1:length(dresp)
     62    ldata(i)=length(dresp(i).impfac);
    2663end
    27 data=zeros(length(rfunc),max(ldata));
    28 dvar=rfunc(find(ldata == max(ldata),1,'first')).desvar;
     64data=zeros(length(dresp),max(ldata));
     65dvar=dresp(find(ldata == max(ldata),1,'first')).var;
    2966
    30 for i=1:length(rfunc)
    31     desc(i)=cellstr(rfunc(i).descriptor);
    32     data(i,1:ldata(i))=rfunc(i).impfac;
     67for i=1:length(dresp)
     68    desc(i)=cellstr(dresp(i).descriptor);
     69    data(i,1:ldata(i))=dresp(i).impfac;
    3370end
    3471
     
    3673
    3774if (isort)
    38     ipmax=max(data,[],1);
     75    ifmean=mean(data,1);
    3976    if (isort > 0)
    40         [ipmax,index]=sort(ipmax,'descend');
     77        [ifmean,index]=sort(ifmean,'descend');
    4178    else
    42         [ipmax,index]=sort(ipmax,'ascend' );
     79        [ifmean,index]=sort(ifmean,'ascend' );
    4380    end
    44     clear ipmax
     81    clear ifmean
    4582   
    4683    dvar=dvar(index);
     
    96133%  so add an extra row, then reduce xlim
    97134
    98 if length(rfunc) == 1
     135if length(dresp) == 1
    99136    data=[data; data];
    100137end
     
    104141ax1=gca;
    105142set(ax1,'ylim',[0 1.2])
    106 if length(rfunc) == 1
     143if length(dresp) == 1
    107144    set(ax1,'xlim',[0.5 1.5])
    108145end
     
    112149
    113150title('Importance Factors')
    114 xlabel('Response Function')
     151xlabel('Response')
    115152ylabel('Importance Factor Value')
    116153
  • issm/trunk/src/m/solutions/dakota/plot_normdist_bars.m

    r1 r1013  
    22%  plot a stacked bar chart of the sample distributions.
    33%
    4 %  []=plot_normdist_bars(rfunc,plev)
     4%  []=plot_normdist_bars(dresp,plev,lstr)
    55%
    6 function []=plot_normdist_bars(rfunc,plev)
     6%  where the required input is:
     7%    dresp         (structure array, responses)
     8%
     9%  and the optional input is:
     10%    plev          (double vector, probability levels)
     11%    lstr          (cell array, legend labels)
     12%
     13%  the required fields of dresp are:
     14%    descriptor    (char, description)
     15%    sample        (double vector, list of samples)
     16%
     17%  and the optional fields of dresp are:
     18%    mean          (double, mean of sample)
     19%    stddev        (double, standard deviation of sample)
     20%
     21%  for each response in the input array, this function plots
     22%  a stacked bar plot of the list of samples, where the bars
     23%  are stacked by the given or default probability levels
     24%  calculated from a normal distribution, and annotates it with
     25%  the description.  the mean and standard deviation will be
     26%  calculated from the samples if they do not already exist.
     27%  the legend labels can be given or constructed from the
     28%  probability levels.
     29%
     30%  this data would typically be contained in the dakota tabular
     31%  output file and read by dakota_out_parse.
     32%
     33%  "Copyright 2009, by the California Institute of Technology.
     34%  ALL RIGHTS RESERVED. United States Government Sponsorship
     35%  acknowledged. Any commercial use must be negotiated with
     36%  the Office of Technology Transfer at the California Institute
     37%  of Technology.  (NTR 47078)
     38%
     39%  This software may be subject to U.S. export control laws.
     40%  By accepting this  software, the user agrees to comply with
     41%  all applicable U.S. export laws and regulations. User has the
     42%  responsibility to obtain export licenses, or other export
     43%  authority as may be required before exporting such information
     44%  to foreign countries or providing access to foreign persons."
     45%
     46function []=plot_normdist_bars(dresp,plev,lstr)
    747
    848if ~nargin
     
    1757%%  assemble the data into a matrix and calculate the increments
    1858
    19 desc=cell (1,length(rfunc));
    20 data=zeros(length(rfunc),5);
     59desc=cell (1,length(dresp));
     60data=zeros(length(dresp),5);
    2161
    22 if ~isfield(rfunc,'mean') || ~isfield(rfunc,'stddev')
    23     for i=1:length(rfunc)
    24         [rfunc(i).mean,rfunc(i).stddev,...
    25             rfunc(i).meanci,rfunc(i).stddevci]=...
    26             normfit(rfunc(i).sample,0.05);
     62if ~isfield(dresp,'mean') || ~isfield(dresp,'stddev')
     63    for i=1:length(dresp)
     64%  calculate 95% confidence intervals (same as dakota)
     65        [dresp(i).mean,dresp(i).stddev,...
     66            dresp(i).meanci,dresp(i).stddevci]=...
     67            normfit(dresp(i).sample,0.05);
    2768    end
    2869end
    2970
    30 for i=1:length(rfunc)
    31     desc(i)=cellstr(rfunc(i).descriptor);
    32     data(i,:)=norminv(plev,rfunc(i).mean,rfunc(i).stddev);
     71for i=1:length(dresp)
     72    desc(i)=cellstr(dresp(i).descriptor);
     73    data(i,:)=norminv(plev,dresp(i).mean,dresp(i).stddev);
    3374end
    3475
     
    4283%  so add an extra row, then reduce xlim
    4384
    44 if length(rfunc) == 1
     85if length(dresp) == 1
    4586    data=[data; data];
    4687end
     
    5394
    5495ax1=gca;
    55 if length(rfunc) == 1
     96if length(dresp) == 1
    5697    set(ax1,'xlim',[0.5 1.5])
    5798end
    58 set(ax1,'xtick',1:1:max(length(rfunc),2));
     99set(ax1,'xtick',1:1:max(length(dresp),2));
    59100set(ax1,'xticklabel',desc)
    60101
    61102%  add the annotation
    62103
    63 title('Normal Distributions of Design Variables and/or Response Functions')
    64 xlabel('Design Variable or Response Function')
     104title('Normal Distributions of Variables and/or Responses')
     105xlabel('Variable or Response')
    65106ylabel('Value')
    66107
  • issm/trunk/src/m/solutions/dakota/plot_normplot.m

    r1 r1013  
    11%
    2 %  plot a normal probability plot of the response functions.
     2%  plot a normal probability plot of the responses.
    33%
    4 %  []=plot_normplot(rfunc)
     4%  []=plot_normplot(dresp)
    55%
    6 function []=plot_normplot(rfunc)
     6%  where the required input is:
     7%    dresp         (structure array, responses)
     8%
     9%  the required fields of dresp are:
     10%    descriptor    (char, description)
     11%    sample        (double vector, list of samples)
     12%
     13%  for each response in the input array, this function plots
     14%  a matlab normal probability plot of the list of samples
     15%  and annotates it with the description.  the lists of samples
     16%  need not all be the same length.
     17%
     18%  this data would typically be contained in the dakota tabular
     19%  output file and read by dakota_out_parse.
     20%
     21%  "Copyright 2009, by the California Institute of Technology.
     22%  ALL RIGHTS RESERVED. United States Government Sponsorship
     23%  acknowledged. Any commercial use must be negotiated with
     24%  the Office of Technology Transfer at the California Institute
     25%  of Technology.  (NTR 47078)
     26%
     27%  This software may be subject to U.S. export control laws.
     28%  By accepting this  software, the user agrees to comply with
     29%  all applicable U.S. export laws and regulations. User has the
     30%  responsibility to obtain export licenses, or other export
     31%  authority as may be required before exporting such information
     32%  to foreign countries or providing access to foreign persons."
     33%
     34function []=plot_normplot(dresp)
    735
    836if ~nargin
     
    1341%%  assemble the data into a matrix
    1442
    15 desc=cell (1,length(rfunc));
    16 for i=1:length(rfunc)
    17     ldata(i)=length(rfunc(i).sample);
     43desc=cell (1,length(dresp));
     44for i=1:length(dresp)
     45    ldata(i)=length(dresp(i).sample);
    1846end
    19 data=zeros(max(ldata),length(rfunc));
     47data=zeros(max(ldata),length(dresp));
    2048
    21 for i=1:length(rfunc)
    22     desc(i)=cellstr(rfunc(i).descriptor);
    23     data(1:ldata(i),i)=rfunc(i).sample;
     49for i=1:length(dresp)
     50    desc(i)=cellstr(dresp(i).descriptor);
     51    data(1:ldata(i),i)=dresp(i).sample;
    2452end
    2553
     
    3361%  add the annotation
    3462
    35 title('Normal Probability Plot of Design Variables and/or Response Functions')
     63title('Normal Probability Plot of Variables and/or Responses')
    3664xlabel('Value')
    3765ylabel('Probability')
  • issm/trunk/src/m/solutions/dakota/plot_prob_bars.m

    r1 r1013  
    11%
    2 %  plot a stacked bar chart of the probabilities.
     2%  plot a stacked bar chart of the probabilities in the CDF.
    33%
    4 %  []=plot_prob_bars(rfunc,lstr)
     4%  []=plot_prob_bars(dresp,lstr)
    55%
    6 function []=plot_prob_bars(rfunc,lstr)
     6%  where the required input is:
     7%    dresp         (structure array, responses)
     8%
     9%  and the optional input is:
     10%    lstr          (cell array, legend labels)
     11%
     12%  the required fields of dresp are:
     13%    descriptor    (char, description)
     14%    cdf(:,4)      (double matrix, CDF table)
     15%
     16%  for each response in the input array, this function plots
     17%  a stacked bar plot of the responses, where the bars are
     18%  stacked by the probabilities corresponding to the given
     19%  response levels in the CDF, and annotates it with the
     20%  description.  the legend labels can be given or constructed
     21%  from the response levels.
     22%
     23%  this data would typically be contained in the dakota output
     24%  file and read by dakota_out_parse.
     25%
     26%  "Copyright 2009, by the California Institute of Technology.
     27%  ALL RIGHTS RESERVED. United States Government Sponsorship
     28%  acknowledged. Any commercial use must be negotiated with
     29%  the Office of Technology Transfer at the California Institute
     30%  of Technology.  (NTR 47078)
     31%
     32%  This software may be subject to U.S. export control laws.
     33%  By accepting this  software, the user agrees to comply with
     34%  all applicable U.S. export laws and regulations. User has the
     35%  responsibility to obtain export licenses, or other export
     36%  authority as may be required before exporting such information
     37%  to foreign countries or providing access to foreign persons."
     38%
     39function []=plot_prob_bars(dresp,lstr)
    740
    841if ~nargin
     
    1346%%  assemble the data into a matrix and calculate the increments
    1447
    15 desc=cell (1,length(rfunc));
    16 for i=1:length(rfunc)
    17     ldata(i)=size(rfunc(i).cdf,1);
     48desc=cell (1,length(dresp));
     49for i=1:length(dresp)
     50    ldata(i)=size(dresp(i).cdf,1);
    1851end
    19 data=zeros(length(rfunc),max(ldata));
     52data=zeros(length(dresp),max(ldata));
    2053
    21 for i=1:length(rfunc)
    22     desc(i)=cellstr(rfunc(i).descriptor);
    23     if ~isempty(rfunc(i).cdf)
    24     data(i,1)=rfunc(i).cdf(1,2);
    25         for j=2:size(rfunc(i).cdf,1)
    26             if (rfunc(i).cdf(j,2) > rfunc(i).cdf(j-1,2))
    27                 data(i,j)=rfunc(i).cdf(j,2)-rfunc(i).cdf(j-1,2);
     54for i=1:length(dresp)
     55    desc(i)=cellstr(dresp(i).descriptor);
     56    if ~isempty(dresp(i).cdf)
     57    data(i,1)=dresp(i).cdf(1,2);
     58        for j=2:size(dresp(i).cdf,1)
     59            if (dresp(i).cdf(j,2) > dresp(i).cdf(j-1,2))
     60                data(i,j)=dresp(i).cdf(j,2)-dresp(i).cdf(j-1,2);
    2861            end
    2962        end
     
    4073%  so add an extra row, then reduce xlim
    4174
    42 if length(rfunc) == 1
     75if length(dresp) == 1
    4376    data=[data; data];
    4477end
     
    5487ax1=gca;
    5588set(ax1,'ylim',[0 120])
    56 if length(rfunc) == 1
     89if length(dresp) == 1
    5790    set(ax1,'xlim',[0.5 1.5])
    5891end
     
    6194%  add the annotation
    6295
    63 title('Probabilities for Specified Response Levels')
    64 xlabel('Response Function')
     96title('Probabilities for Specified Response Levels (RIA)')
     97xlabel('Response')
    6598ylabel('Percent Below Level')
    6699
     
    69102    for i=1:max(ldata)
    70103        lstr(i)=cellstr(sprintf('%g',...
    71             rfunc(find(ldata == max(ldata),1,'first')).cdf(i,1)));
     104            dresp(find(ldata == max(ldata),1,'first')).cdf(i,1)));
    72105    end
    73106    if ~isempty(find(ldata < max(ldata)))
    74         warning('Variable number of levels for response functions.');
     107        warning('Variable number of levels for responses.');
    75108    end
    76109end
  • issm/trunk/src/m/solutions/dakota/plot_rlev_bars.m

    r1 r1013  
    11%
    2 %  plot a stacked bar chart of the response levels.
     2%  plot a stacked bar chart of the response levels in the cdf.
    33%
    4 %  []=plot_rlev_bars(rfunc,lstr)
     4%  []=plot_rlev_bars(dresp,lstr)
    55%
    6 function []=plot_rlev_bars(rfunc,lstr)
     6%  where the required input is:
     7%    dresp         (structure array, responses)
     8%
     9%  and the optional input is:
     10%    lstr          (cell array, legend labels)
     11%
     12%  the required fields of dresp are:
     13%    descriptor    (char, description)
     14%    cdf(:,4)      (double matrix, CDF table)
     15%
     16%  for each response in the input array, this function plots
     17%  a stacked bar plot of the responses, where the bars are
     18%  stacked by the response levels corresponding to the given
     19%  probabilities in the CDF, and annotates it with the
     20%  description.  the legend labels can be given or constructed
     21%  from the probabilities.
     22%
     23%  this data would typically be contained in the dakota output
     24%  file and read by dakota_out_parse.
     25%
     26%  "Copyright 2009, by the California Institute of Technology.
     27%  ALL RIGHTS RESERVED. United States Government Sponsorship
     28%  acknowledged. Any commercial use must be negotiated with
     29%  the Office of Technology Transfer at the California Institute
     30%  of Technology.  (NTR 47078)
     31%
     32%  This software may be subject to U.S. export control laws.
     33%  By accepting this  software, the user agrees to comply with
     34%  all applicable U.S. export laws and regulations. User has the
     35%  responsibility to obtain export licenses, or other export
     36%  authority as may be required before exporting such information
     37%  to foreign countries or providing access to foreign persons."
     38%
     39function []=plot_rlev_bars(dresp,lstr)
    740
    841if ~nargin
     
    1346%%  assemble the data into a matrix and calculate the increments
    1447
    15 desc=cell (1,length(rfunc));
    16 for i=1:length(rfunc)
    17     ldata(i)=size(rfunc(i).cdf,1);
     48desc=cell (1,length(dresp));
     49for i=1:length(dresp)
     50    ldata(i)=size(dresp(i).cdf,1);
    1851end
    19 data=zeros(length(rfunc),max(ldata));
     52data=zeros(length(dresp),max(ldata));
    2053
    21 for i=1:length(rfunc)
    22     desc(i)=cellstr(rfunc(i).descriptor);
    23     if ~isempty(rfunc(i).cdf)
    24         data(i,1)=rfunc(i).cdf(1,1);
    25         for j=2:size(rfunc(i).cdf,1)
    26             if (rfunc(i).cdf(j,1) > rfunc(i).cdf(j-1,1))
    27                 data(i,j)=rfunc(i).cdf(j,1)-rfunc(i).cdf(j-1,1);
     54for i=1:length(dresp)
     55    desc(i)=cellstr(dresp(i).descriptor);
     56    if ~isempty(dresp(i).cdf)
     57        data(i,1)=dresp(i).cdf(1,1);
     58        for j=2:size(dresp(i).cdf,1)
     59            if (dresp(i).cdf(j,1) > dresp(i).cdf(j-1,1))
     60                data(i,j)=dresp(i).cdf(j,1)-dresp(i).cdf(j-1,1);
    2861            end
    2962        end
     
    3669%  so add an extra row, then reduce xlim
    3770
    38 if length(rfunc) == 1
     71if length(dresp) == 1
    3972    data=[data; data];
    4073end
     
    4780
    4881ax1=gca;
    49 if length(rfunc) == 1
     82if length(dresp) == 1
    5083    set(ax1,'xlim',[0.5 1.5])
    5184end
     
    5487%  add the annotation
    5588
    56 title('Response Levels for Specified Probabilities')
    57 xlabel('Response Function')
     89title('Response Levels for Specified Probabilities (PMA)')
     90xlabel('Response')
    5891ylabel('Response Level')
    5992
     
    6295    for i=1:max(ldata)
    6396        lstr(i)=cellstr(sprintf('%g%%',...
    64             100*rfunc(find(ldata == max(ldata),1,'first')).cdf(i,2)));
     97            100*dresp(find(ldata == max(ldata),1,'first')).cdf(i,2)));
    6598    end
    6699    if ~isempty(find(ldata < max(ldata)))
    67         warning('Variable number of probabilities for response functions.');
     100        warning('Variable number of probabilities for responses.');
    68101    end
    69102end
  • issm/trunk/src/m/solutions/dakota/plot_sampdist_bars.m

    r1 r1013  
    22%  plot a stacked bar chart of the sample distributions.
    33%
    4 %  []=plot_sampdist_bars(rfunc)
     4%  []=plot_sampdist_bars(dresp,lstr)
    55%
    6 function []=plot_sampdist_bars(rfunc)
     6%  where the required input is:
     7%    dresp         (structure array, responses)
     8%
     9%  and the optional input is:
     10%    lstr          (cell array, legend labels)
     11%
     12%  the required fields of dresp are:
     13%    descriptor    (char, description)
     14%    sample        (double vector, list of samples)
     15%
     16%  and the optional fields of dresp are:
     17%    min           (double, minimum of sample)
     18%    quart1        (double, first quartile of sample)
     19%    median        (double, median of sample)
     20%    quart3        (double, third quartile of sample)
     21%    max           (double, maximum of sample)
     22%
     23%  for each response in the input array, this function plots
     24%  a stacked bar plot of the list of samples, where the bars
     25%  are stacked by the four quartiles, and annotates it with
     26%  the description.  the quartiles will be calculated from the
     27%  samples if they do not already exist.
     28%
     29%  this data would typically be contained in the dakota tabular
     30%  output file and read by dakota_out_parse.
     31%
     32%  "Copyright 2009, by the California Institute of Technology.
     33%  ALL RIGHTS RESERVED. United States Government Sponsorship
     34%  acknowledged. Any commercial use must be negotiated with
     35%  the Office of Technology Transfer at the California Institute
     36%  of Technology.  (NTR 47078)
     37%
     38%  This software may be subject to U.S. export control laws.
     39%  By accepting this  software, the user agrees to comply with
     40%  all applicable U.S. export laws and regulations. User has the
     41%  responsibility to obtain export licenses, or other export
     42%  authority as may be required before exporting such information
     43%  to foreign countries or providing access to foreign persons."
     44%
     45function []=plot_sampdist_bars(dresp,lstr)
    746
    847if ~nargin
     
    1352%%  assemble the data into a matrix and calculate the increments
    1453
    15 desc=cell (1,length(rfunc));
    16 data=zeros(length(rfunc),5);
     54desc=cell (1,length(dresp));
     55data=zeros(length(dresp),5);
    1756
    18 if ~isfield(rfunc,'min')    || ~isfield(rfunc,'quart1') || ...
    19    ~isfield(rfunc,'median') || ~isfield(rfunc,'quart3') || ...
    20    ~isfield(rfunc,'max')
    21     for i=1:length(rfunc)
    22         rfunc(i).min   =min    (rfunc(i).sample);
    23         rfunc(i).quart1=prctile(rfunc(i).sample,25);
    24         rfunc(i).median=median (rfunc(i).sample);
    25         rfunc(i).quart3=prctile(rfunc(i).sample,75);
    26         rfunc(i).max   =max    (rfunc(i).sample);
     57if ~isfield(dresp,'min')    || ~isfield(dresp,'quart1') || ...
     58   ~isfield(dresp,'median') || ~isfield(dresp,'quart3') || ...
     59   ~isfield(dresp,'max')
     60    for i=1:length(dresp)
     61        dresp(i).min   =min    (dresp(i).sample);
     62        dresp(i).quart1=prctile(dresp(i).sample,25);
     63        dresp(i).median=median (dresp(i).sample);
     64        dresp(i).quart3=prctile(dresp(i).sample,75);
     65        dresp(i).max   =max    (dresp(i).sample);
    2766    end
    2867end
    2968
    30 for i=1:length(rfunc)
    31     desc(i)=cellstr(rfunc(i).descriptor);
    32     data(i,1)=rfunc(i).min;
    33     data(i,2)=rfunc(i).quart1-rfunc(i).min;
    34     data(i,3)=rfunc(i).median-rfunc(i).quart1;
    35     data(i,4)=rfunc(i).quart3-rfunc(i).median;
    36     data(i,5)=rfunc(i).max   -rfunc(i).quart3;
     69for i=1:length(dresp)
     70    desc(i)=cellstr(dresp(i).descriptor);
     71    data(i,1)=dresp(i).min;
     72    data(i,2)=dresp(i).quart1-dresp(i).min;
     73    data(i,3)=dresp(i).median-dresp(i).quart1;
     74    data(i,4)=dresp(i).quart3-dresp(i).median;
     75    data(i,5)=dresp(i).max   -dresp(i).quart3;
    3776end
    3877
     
    4281%  so add an extra row, then reduce xlim
    4382
    44 if length(rfunc) == 1
     83if length(dresp) == 1
    4584    data=[data; data];
    4685end
     
    5392
    5493ax1=gca;
    55 if length(rfunc) == 1
     94if length(dresp) == 1
    5695    set(ax1,'xlim',[0.5 1.5])
    5796end
    58 set(ax1,'xtick',1:1:max(length(rfunc),2));
     97set(ax1,'xtick',1:1:max(length(dresp),2));
    5998set(ax1,'xticklabel',desc)
    6099
    61100%  add the annotation
    62101
    63 title('Sample Distributions of Design Variables and/or Response Functions')
    64 xlabel('Design Variable or Response Function')
     102title('Sample Distributions of Variables and/or Responses')
     103xlabel('Variable or Response')
    65104ylabel('Value')
    66105
Note: See TracChangeset for help on using the changeset viewer.