-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathosansw.m
103 lines (87 loc) · 3.12 KB
/
osansw.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
function [answ,answs,pm]=osansw(th0,covX,E,v)
% [answ,answs,pm]=OSANSW(th0,covX,E,v)
%
% Constructs some reporting strings for MLEOS, MLEROS, MLEROS, MLEOSL,
% thus for correlated and uncorrelated loading scenarios as well as the
% single-field estimate (which does not require the third and fourth input.)
%
% INPUT:
%
% th0 True parameter vector that you want quoted
% covX The estimation covariance that you want quoted
% E Young's modulus [Pa] (for dual fields, using DTOTE)
% v Poisson's ratio ] (for dual fields, using DTOTE)
%
% OUTPUT:
%
% answ A cell with the "answers" if you will
% answs Appropriate formatting strings for a plot title
% pm The plusminus sign
%
% SEE ALSO: OSDISP, DTOTE
%
% Last modified by fjsimons-at-alum.mit.edu, 10/23/2023
% Last modified by olwalbert-at-princeton.edu, 08/15/2024
defval('th0',[])
defval('covX',[])
defval('E',[])
defval('v',[])
if all(isempty([th0 covX(:)' E v]))
answ={''};
answs='%s';
end
% The plus-minus sign
pm=str2mat(177);
% Dual-field analysis with no business for E or v
if ~isempty(E) && ~isempty(v)
% Conversion to Te [m]
Te=DtoTe(th0(1),E,v);
% This will come awfully close. We remember to put in the mean!
stdTe=std(DtoTe(th0(1)+randn(10000,1)*sqrt(covX(1,1)),E,v));
stdf2=sqrt(covX(2,2));
% Here is the "delta method", which is approximate
stdTedelta=sqrt(covX(1,1))/th0(1)^(2/3)/3*[12*(1-v^2)/E]^(1/3);
disp(sprintf('Stdv of the Te predicted by simulation: %3.2f km', stdTe/1000))
disp(sprintf('Stdv of the Te predicted by delta meth: %3.2f km\n',stdTedelta/1000))
% True parameters and their purported uncertainties
answ{1}=sprintf('E = %g',E);
answ{2}=sprintf('%s = %g','\nu',v);
answ{3}=sprintf('T_e = %4.1f %s %3.1f km',...
round(Te/1e3*10)/10,pm,round(stdTe/1e3*10)/10);
answ{4}=sprintf('f^2 = %g %s %g',...
th0(2),pm,round(stdf2*1e3)/1e3);
end
% Some common strings
s2s='%s^2 = %6.2f %s %6.2f';
nus='%s = %4.2f %s %4.2f';
rhs='%s = %6.2f %s %6.2f';
if length(th0)==3
% Single-field analysis (MLEOSL etc)
stds2 =sqrt(covX(1,1));
stdnu =sqrt(covX(2,2));
stdrho =sqrt(covX(3,3));
answ{1}=sprintf(s2s,'\sigma',th0(1),pm,stds2);
answ{2}=sprintf(nus,'\nu', th0(2),pm,stdnu);
answ{3}=sprintf(rhs,'\rho', round(th0(3)),pm,round(stdrho));
answs=['%s ; %s ; %s'];
elseif length(th0)==5
% Uncorrelated dual-field analysis (MLEOS etc)
stds2 =sqrt(covX(3,3));
stdnu =sqrt(covX(4,4));
stdrho =sqrt(covX(5,5));
answ{5}=sprintf(s2s,'\sigma',th0(3),pm,stds2);
answ{6}=sprintf(nus,'\nu', th0(4),pm,stdnu);
answ{7}=sprintf(rhs,'\rho', round(th0(5)),pm,round(stdrho));
answs=['%s ; %s ; %s ; %s\n %s ; %s ; %s'];
elseif length(th0)==6
% Correlated dual-field analysis (MLEROS etc)
stdr =sqrt(covX(3,3));
stds2 =sqrt(covX(4,4));
stdnu =sqrt(covX(5,5));
stdrho =sqrt(covX(6,6));
answ{5}=sprintf('r = %g %s %g',th0(3),pm,round(stdr*1e3)/1e3);
answ{6}=sprintf(s2s,'\sigma', th0(4),pm,stds2);
answ{7}=sprintf(nus,'\nu', th0(5),pm,stdnu);
answ{8}=sprintf(rhs,'\rho', round(th0(6)),pm,round(stdrho));
answs=['%s ; %s ; %s ; %s ; %s\n %s ; %s ; %s'];
end