Changeset 1013
- Timestamp:
- 06/15/09 15:07:31 (16 years ago)
- 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 1 1 % 2 % plot a box plot of the response functions.2 % plot a box plot of the responses. 3 3 % 4 % []=plot_boxplot( rfunc)4 % []=plot_boxplot(dresp) 5 5 % 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 % 34 function []=plot_boxplot(dresp) 7 35 8 36 if ~nargin … … 13 41 %% assemble the data into a matrix 14 42 15 desc=cell (1,length( rfunc));16 for i=1:length( rfunc)17 ldata(i)=length( rfunc(i).sample);43 desc=cell (1,length(dresp)); 44 for i=1:length(dresp) 45 ldata(i)=length(dresp(i).sample); 18 46 end 19 data=zeros(max(ldata),length( rfunc));47 data=zeros(max(ldata),length(dresp)); 20 48 21 for i=1:length( rfunc)22 desc(i)=cellstr( rfunc(i).descriptor);23 data(1:ldata(i),i)= rfunc(i).sample;49 for i=1:length(dresp) 50 desc(i)=cellstr(dresp(i).descriptor); 51 data(1:ldata(i),i)=dresp(i).sample; 24 52 end 25 53 … … 33 61 % add the annotation 34 62 35 title('Box Plot of Design Variables and/or Response Functions')36 xlabel(' Design Variable or Response Function')63 title('Box Plot of Variables and/or Responses') 64 xlabel('Variable or Response') 37 65 ylabel('Value') 38 66 -
issm/trunk/src/m/solutions/dakota/plot_hist_norm.m
r1 r1013 1 1 % 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." 6 56 % 7 57 function []=plot_hist_norm(varargin) … … 16 66 ivar=1; 17 67 if isstruct(varargin{ivar}) 18 rfunc1=varargin{ivar};68 dresp1=varargin{ivar}; 19 69 ivar=ivar+1; 20 70 21 desc=cell (1,length( rfunc1));22 l data=zeros(1,length(rfunc1));23 for i=1:length( rfunc1)24 l data(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 83 else 84 samp=varargin{ivar}; 35 85 ivar=ivar+1; 36 86 37 l data(1:size(data,2))=size(data,1);87 lsamp(1:size(samp,2))=size(samp,1); 38 88 39 89 if ivar <= nargin && iscell(varargin{ivar}) … … 46 96 47 97 if 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; 57 107 end 58 108 elseif ivar+1 <= nargin … … 61 111 mu =varargin{ivar}; 62 112 else 63 mu =mean( data);113 mu =mean(samp); 64 114 display('Using calculated means.') 65 115 end … … 70 120 sigma=varargin{ivar}; 71 121 else 72 sigma=std( data);122 sigma=std(samp); 73 123 display('Using calculated standard deviations.') 74 124 end … … 82 132 hmin=varargin{ivar}; 83 133 else 84 hmin=min(min( data));134 hmin=min(min(samp)); 85 135 end 86 136 ivar=ivar+1; … … 88 138 hmax=varargin{ivar}; 89 139 else 90 hmax=max(max( data));140 hmax=max(max(samp)); 91 141 end 92 142 ivar=ivar+1; … … 107 157 % Use -inf and inf in edges to include all non-NaN values. 108 158 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) /l data(i);113 dabove(i) =length(find( data(:,i)>edges(end)))/ldata(i);159 dhistc=histc(samp,edges); 160 for 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); 114 164 end 115 165 116 166 if exist('mu','var') && exist('sigma','var') 117 ncol=size( data,2);167 ncol=size(samp,2); 118 168 for i=1:ncol 119 169 dbelow(ncol+i)=normcdf(edges( 1),mu(i),sigma(i)); -
issm/trunk/src/m/solutions/dakota/plot_if_bars.m
r1 r1013 2 2 % plot a stacked bar chart of the importance factors. 3 3 % 4 % []=plot_if_bars( rfunc,ifmin,isort)4 % []=plot_if_bars(dresp,ifmin,isort) 5 5 % 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 % 43 function []=plot_if_bars(dresp,ifmin,isort) 7 44 8 45 if ~nargin … … 21 58 %% assemble the data into a matrix 22 59 23 desc=cell (1,length( rfunc));24 for i=1:length( rfunc)25 ldata(i)=length( rfunc(i).impfac);60 desc=cell (1,length(dresp)); 61 for i=1:length(dresp) 62 ldata(i)=length(dresp(i).impfac); 26 63 end 27 data=zeros(length( rfunc),max(ldata));28 dvar= rfunc(find(ldata == max(ldata),1,'first')).desvar;64 data=zeros(length(dresp),max(ldata)); 65 dvar=dresp(find(ldata == max(ldata),1,'first')).var; 29 66 30 for i=1:length( rfunc)31 desc(i)=cellstr( rfunc(i).descriptor);32 data(i,1:ldata(i))= rfunc(i).impfac;67 for i=1:length(dresp) 68 desc(i)=cellstr(dresp(i).descriptor); 69 data(i,1:ldata(i))=dresp(i).impfac; 33 70 end 34 71 … … 36 73 37 74 if (isort) 38 i pmax=max(data,[],1);75 ifmean=mean(data,1); 39 76 if (isort > 0) 40 [i pmax,index]=sort(ipmax,'descend');77 [ifmean,index]=sort(ifmean,'descend'); 41 78 else 42 [i pmax,index]=sort(ipmax,'ascend' );79 [ifmean,index]=sort(ifmean,'ascend' ); 43 80 end 44 clear i pmax81 clear ifmean 45 82 46 83 dvar=dvar(index); … … 96 133 % so add an extra row, then reduce xlim 97 134 98 if length( rfunc) == 1135 if length(dresp) == 1 99 136 data=[data; data]; 100 137 end … … 104 141 ax1=gca; 105 142 set(ax1,'ylim',[0 1.2]) 106 if length( rfunc) == 1143 if length(dresp) == 1 107 144 set(ax1,'xlim',[0.5 1.5]) 108 145 end … … 112 149 113 150 title('Importance Factors') 114 xlabel('Response Function')151 xlabel('Response') 115 152 ylabel('Importance Factor Value') 116 153 -
issm/trunk/src/m/solutions/dakota/plot_normdist_bars.m
r1 r1013 2 2 % plot a stacked bar chart of the sample distributions. 3 3 % 4 % []=plot_normdist_bars( rfunc,plev)4 % []=plot_normdist_bars(dresp,plev,lstr) 5 5 % 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 % 46 function []=plot_normdist_bars(dresp,plev,lstr) 7 47 8 48 if ~nargin … … 17 57 %% assemble the data into a matrix and calculate the increments 18 58 19 desc=cell (1,length( rfunc));20 data=zeros(length( rfunc),5);59 desc=cell (1,length(dresp)); 60 data=zeros(length(dresp),5); 21 61 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); 62 if ~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); 27 68 end 28 69 end 29 70 30 for i=1:length( rfunc)31 desc(i)=cellstr( rfunc(i).descriptor);32 data(i,:)=norminv(plev, rfunc(i).mean,rfunc(i).stddev);71 for i=1:length(dresp) 72 desc(i)=cellstr(dresp(i).descriptor); 73 data(i,:)=norminv(plev,dresp(i).mean,dresp(i).stddev); 33 74 end 34 75 … … 42 83 % so add an extra row, then reduce xlim 43 84 44 if length( rfunc) == 185 if length(dresp) == 1 45 86 data=[data; data]; 46 87 end … … 53 94 54 95 ax1=gca; 55 if length( rfunc) == 196 if length(dresp) == 1 56 97 set(ax1,'xlim',[0.5 1.5]) 57 98 end 58 set(ax1,'xtick',1:1:max(length( rfunc),2));99 set(ax1,'xtick',1:1:max(length(dresp),2)); 59 100 set(ax1,'xticklabel',desc) 60 101 61 102 % add the annotation 62 103 63 title('Normal Distributions of Design Variables and/or Response Functions')64 xlabel(' Design Variable or Response Function')104 title('Normal Distributions of Variables and/or Responses') 105 xlabel('Variable or Response') 65 106 ylabel('Value') 66 107 -
issm/trunk/src/m/solutions/dakota/plot_normplot.m
r1 r1013 1 1 % 2 % plot a normal probability plot of the response functions.2 % plot a normal probability plot of the responses. 3 3 % 4 % []=plot_normplot( rfunc)4 % []=plot_normplot(dresp) 5 5 % 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 % 34 function []=plot_normplot(dresp) 7 35 8 36 if ~nargin … … 13 41 %% assemble the data into a matrix 14 42 15 desc=cell (1,length( rfunc));16 for i=1:length( rfunc)17 ldata(i)=length( rfunc(i).sample);43 desc=cell (1,length(dresp)); 44 for i=1:length(dresp) 45 ldata(i)=length(dresp(i).sample); 18 46 end 19 data=zeros(max(ldata),length( rfunc));47 data=zeros(max(ldata),length(dresp)); 20 48 21 for i=1:length( rfunc)22 desc(i)=cellstr( rfunc(i).descriptor);23 data(1:ldata(i),i)= rfunc(i).sample;49 for i=1:length(dresp) 50 desc(i)=cellstr(dresp(i).descriptor); 51 data(1:ldata(i),i)=dresp(i).sample; 24 52 end 25 53 … … 33 61 % add the annotation 34 62 35 title('Normal Probability Plot of Design Variables and/or Response Functions')63 title('Normal Probability Plot of Variables and/or Responses') 36 64 xlabel('Value') 37 65 ylabel('Probability') -
issm/trunk/src/m/solutions/dakota/plot_prob_bars.m
r1 r1013 1 1 % 2 % plot a stacked bar chart of the probabilities .2 % plot a stacked bar chart of the probabilities in the CDF. 3 3 % 4 % []=plot_prob_bars( rfunc,lstr)4 % []=plot_prob_bars(dresp,lstr) 5 5 % 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 % 39 function []=plot_prob_bars(dresp,lstr) 7 40 8 41 if ~nargin … … 13 46 %% assemble the data into a matrix and calculate the increments 14 47 15 desc=cell (1,length( rfunc));16 for i=1:length( rfunc)17 ldata(i)=size( rfunc(i).cdf,1);48 desc=cell (1,length(dresp)); 49 for i=1:length(dresp) 50 ldata(i)=size(dresp(i).cdf,1); 18 51 end 19 data=zeros(length( rfunc),max(ldata));52 data=zeros(length(dresp),max(ldata)); 20 53 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);54 for 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); 28 61 end 29 62 end … … 40 73 % so add an extra row, then reduce xlim 41 74 42 if length( rfunc) == 175 if length(dresp) == 1 43 76 data=[data; data]; 44 77 end … … 54 87 ax1=gca; 55 88 set(ax1,'ylim',[0 120]) 56 if length( rfunc) == 189 if length(dresp) == 1 57 90 set(ax1,'xlim',[0.5 1.5]) 58 91 end … … 61 94 % add the annotation 62 95 63 title('Probabilities for Specified Response Levels ')64 xlabel('Response Function')96 title('Probabilities for Specified Response Levels (RIA)') 97 xlabel('Response') 65 98 ylabel('Percent Below Level') 66 99 … … 69 102 for i=1:max(ldata) 70 103 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))); 72 105 end 73 106 if ~isempty(find(ldata < max(ldata))) 74 warning('Variable number of levels for response functions.');107 warning('Variable number of levels for responses.'); 75 108 end 76 109 end -
issm/trunk/src/m/solutions/dakota/plot_rlev_bars.m
r1 r1013 1 1 % 2 % plot a stacked bar chart of the response levels .2 % plot a stacked bar chart of the response levels in the cdf. 3 3 % 4 % []=plot_rlev_bars( rfunc,lstr)4 % []=plot_rlev_bars(dresp,lstr) 5 5 % 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 % 39 function []=plot_rlev_bars(dresp,lstr) 7 40 8 41 if ~nargin … … 13 46 %% assemble the data into a matrix and calculate the increments 14 47 15 desc=cell (1,length( rfunc));16 for i=1:length( rfunc)17 ldata(i)=size( rfunc(i).cdf,1);48 desc=cell (1,length(dresp)); 49 for i=1:length(dresp) 50 ldata(i)=size(dresp(i).cdf,1); 18 51 end 19 data=zeros(length( rfunc),max(ldata));52 data=zeros(length(dresp),max(ldata)); 20 53 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);54 for 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); 28 61 end 29 62 end … … 36 69 % so add an extra row, then reduce xlim 37 70 38 if length( rfunc) == 171 if length(dresp) == 1 39 72 data=[data; data]; 40 73 end … … 47 80 48 81 ax1=gca; 49 if length( rfunc) == 182 if length(dresp) == 1 50 83 set(ax1,'xlim',[0.5 1.5]) 51 84 end … … 54 87 % add the annotation 55 88 56 title('Response Levels for Specified Probabilities ')57 xlabel('Response Function')89 title('Response Levels for Specified Probabilities (PMA)') 90 xlabel('Response') 58 91 ylabel('Response Level') 59 92 … … 62 95 for i=1:max(ldata) 63 96 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))); 65 98 end 66 99 if ~isempty(find(ldata < max(ldata))) 67 warning('Variable number of probabilities for response functions.');100 warning('Variable number of probabilities for responses.'); 68 101 end 69 102 end -
issm/trunk/src/m/solutions/dakota/plot_sampdist_bars.m
r1 r1013 2 2 % plot a stacked bar chart of the sample distributions. 3 3 % 4 % []=plot_sampdist_bars( rfunc)4 % []=plot_sampdist_bars(dresp,lstr) 5 5 % 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 % 45 function []=plot_sampdist_bars(dresp,lstr) 7 46 8 47 if ~nargin … … 13 52 %% assemble the data into a matrix and calculate the increments 14 53 15 desc=cell (1,length( rfunc));16 data=zeros(length( rfunc),5);54 desc=cell (1,length(dresp)); 55 data=zeros(length(dresp),5); 17 56 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);57 if ~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); 27 66 end 28 67 end 29 68 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;69 for 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; 37 76 end 38 77 … … 42 81 % so add an extra row, then reduce xlim 43 82 44 if length( rfunc) == 183 if length(dresp) == 1 45 84 data=[data; data]; 46 85 end … … 53 92 54 93 ax1=gca; 55 if length( rfunc) == 194 if length(dresp) == 1 56 95 set(ax1,'xlim',[0.5 1.5]) 57 96 end 58 set(ax1,'xtick',1:1:max(length( rfunc),2));97 set(ax1,'xtick',1:1:max(length(dresp),2)); 59 98 set(ax1,'xticklabel',desc) 60 99 61 100 % add the annotation 62 101 63 title('Sample Distributions of Design Variables and/or Response Functions')64 xlabel(' Design Variable or Response Function')102 title('Sample Distributions of Variables and/or Responses') 103 xlabel('Variable or Response') 65 104 ylabel('Value') 66 105
Note:
See TracChangeset
for help on using the changeset viewer.