/usr/lib/python2.7/dist-packages/openturns/uncertainty.py is in python-openturns 1.9-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 | # This file was automatically generated by SWIG (http://www.swig.org).
# Version 3.0.12
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.
"""Probabilistic meta-package."""
from sys import version_info as _swig_python_version_info
if _swig_python_version_info >= (2, 7, 0):
def swig_import_helper():
import importlib
pkg = __name__.rpartition('.')[0]
mname = '.'.join((pkg, '_uncertainty')).lstrip('.')
try:
return importlib.import_module(mname)
except ImportError:
return importlib.import_module('_uncertainty')
_uncertainty = swig_import_helper()
del swig_import_helper
elif _swig_python_version_info >= (2, 6, 0):
def swig_import_helper():
from os.path import dirname
import imp
fp = None
try:
fp, pathname, description = imp.find_module('_uncertainty', [dirname(__file__)])
except ImportError:
import _uncertainty
return _uncertainty
try:
_mod = imp.load_module('_uncertainty', fp, pathname, description)
finally:
if fp is not None:
fp.close()
return _mod
_uncertainty = swig_import_helper()
del swig_import_helper
else:
import _uncertainty
del _swig_python_version_info
try:
_swig_property = property
except NameError:
pass # Python < 2.2 doesn't have 'property'.
try:
import builtins as __builtin__
except ImportError:
import __builtin__
def _swig_setattr_nondynamic(self, class_type, name, value, static=1):
if (name == "thisown"):
return self.this.own(value)
if (name == "this"):
if type(value).__name__ == 'SwigPyObject':
self.__dict__[name] = value
return
method = class_type.__swig_setmethods__.get(name, None)
if method:
return method(self, value)
if (not static):
if _newclass:
object.__setattr__(self, name, value)
else:
self.__dict__[name] = value
else:
raise AttributeError("You cannot add attributes to %s" % self)
def _swig_setattr(self, class_type, name, value):
return _swig_setattr_nondynamic(self, class_type, name, value, 0)
def _swig_getattr(self, class_type, name):
if (name == "thisown"):
return self.this.own()
method = class_type.__swig_getmethods__.get(name, None)
if method:
return method(self)
raise AttributeError("'%s' object has no attribute '%s'" % (class_type.__name__, name))
def _swig_repr(self):
try:
strthis = "proxy of " + self.this.__repr__()
except __builtin__.Exception:
strthis = ""
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
try:
_object = object
_newclass = 1
except __builtin__.Exception:
class _object:
pass
_newclass = 0
class SwigPyIterator(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, SwigPyIterator, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, SwigPyIterator, name)
def __init__(self, *args, **kwargs):
raise AttributeError("No constructor defined - class is abstract")
__repr__ = _swig_repr
__swig_destroy__ = _uncertainty.delete_SwigPyIterator
__del__ = lambda self: None
def value(self):
return _uncertainty.SwigPyIterator_value(self)
def incr(self, n=1):
return _uncertainty.SwigPyIterator_incr(self, n)
def decr(self, n=1):
return _uncertainty.SwigPyIterator_decr(self, n)
def distance(self, x):
return _uncertainty.SwigPyIterator_distance(self, x)
def equal(self, x):
return _uncertainty.SwigPyIterator_equal(self, x)
def copy(self):
return _uncertainty.SwigPyIterator_copy(self)
def next(self):
return _uncertainty.SwigPyIterator_next(self)
def __next__(self):
return _uncertainty.SwigPyIterator___next__(self)
def previous(self):
return _uncertainty.SwigPyIterator_previous(self)
def advance(self, n):
return _uncertainty.SwigPyIterator_advance(self, n)
def __eq__(self, x):
return _uncertainty.SwigPyIterator___eq__(self, x)
def __ne__(self, x):
return _uncertainty.SwigPyIterator___ne__(self, x)
def __iadd__(self, n):
return _uncertainty.SwigPyIterator___iadd__(self, n)
def __isub__(self, n):
return _uncertainty.SwigPyIterator___isub__(self, n)
def __add__(self, n):
return _uncertainty.SwigPyIterator___add__(self, n)
def __sub__(self, *args):
return _uncertainty.SwigPyIterator___sub__(self, *args)
def __iter__(self):
return self
SwigPyIterator_swigregister = _uncertainty.SwigPyIterator_swigregister
SwigPyIterator_swigregister(SwigPyIterator)
GCC_VERSION = _uncertainty.GCC_VERSION
class TestFailed:
"""TestFailed is used to raise an uniform exception in tests."""
__type = "TestFailed"
def __init__(self, reason=""):
self.reason = reason
def type(self):
return TestFailed.__type
def what(self):
return self.reason
def __str__(self):
return TestFailed.__type + ": " + self.reason
def __lshift__(self, ch):
self.reason += ch
return self
import openturns.base
import openturns.common
import openturns.typ
import openturns.statistics
import openturns.graph
import openturns.func
import openturns.geom
import openturns.diff
import openturns.optim
import openturns.experiment
import openturns.solver
import openturns.algo
import openturns.model_copula
import openturns.randomvector
import openturns.dist_bundle1
import openturns.dist_bundle2
import openturns.weightedexperiment
import openturns.classification
import openturns.orthogonalbasis
import openturns.metamodel
class TaylorExpansionMoments(openturns.common.PersistentObject):
"""
First and second order Taylor expansion formulas.
Available constructors:
TaylorExpansionMoments(*limitStateVariable*)
Parameters
----------
limitStateVariable : :class:`~openturns.RandomVector`
This RandomVector must be of type *Composite*, which means it must have
been defined with the fourth usage of declaration of a RandomVector
(from a Function and an antecedent Distribution) or with
the class :class:`~openturns.CompositeRandomVector`.
Notes
-----
In a probabilistic approach the Taylor expansion can be used
propagate the uncertainties of the input variables :math:`\\uX` through the
model :math:`h` towards the output variables :math:`\\uY`. It enables to access
the central dispersion (Expectation, Variance) of the output variables.
This method is based on a Taylor decomposition of the output variable
:math:`\\uY` towards the :math:`\\uX` random vectors around the mean point
:math:`\\muX`. Depending on the order of the Taylor decomposition (classically
first order or second order), one can obtain different formulas introduced
hereafter.
As :math:`\\uY=h(\\uX)`, the Taylor decomposition around :math:`\\ux = \\muX` at
the second order yields to:
.. math::
\\uY = h(\\muX) + <\\vect{\\vect{\\nabla}}h(\\muX) , \\: \\uX - \\muX> + \\frac{1}{2}<<\\vect{\\vect{\\vect{\\nabla }}}^2 h(\\muX,\\: \\vect{\\mu}_{\\:X}),\\: \\uX - \\muX>,\\: \\uX - \\muX> + o(\\Cov \\uX)
where:
- :math:`\\muX = \\Expect{\\uX}` is the vector of the input variables at the mean
values of each component.
- :math:`\\Cov \\uX` is the covariance matrix of the random vector `\\uX`. The
elements are the followings :
:math:`(\\Cov \\uX)_{ij} = \\Expect{\\left(X^i - \\Expect{X^i} \\right)^2}`
- :math:`\\vect{\\vect{\\nabla}} h(\\muX) = \\: \\Tr{\\left( \\frac{\\partial y^i}{\\partial x^j}\\right)}_{\\ux\\: =\\: \\muX} = \\: \\Tr{\\left( \\frac{\\partial h^i(\\ux)}{\\partial x^j}\\right)}_{\\ux\\: =\\: \\muX}`
is the transposed Jacobian matrix with :math:`i=1,\\ldots,n_Y` and
:math:`j=1,\\ldots,n_X`.
- :math:`\\vect{\\vect{\\vect{\\nabla^2}}} h(\\ux\\:,\\ux)` is a tensor of order 3. It
is composed by the second order derivative towards the :math:`i^\\textrm{th}`
and :math:`j^\\textrm{th}` components of :math:`\\ux` of the
:math:`k^\\textrm{th}` component of the output vector :math:`h(\\ux)`. It
yields to:
:math:`\\left( \\nabla^2 h(\\ux) \\right)_{ijk} = \\frac{\\partial^2 (h^k(\\ux))}{\\partial x^i \\partial x^j}`
- :math:`<\\vect{\\vect{\\nabla}}h(\\muX) , \\: \\uX - \\muX> = \\sum_{j=1}^{n_X} \\left( \\frac{\\partial {\\uy}}{\\partial {x^j}}\\right)_{\\ux = \\muX} . \\left( X^j-\\muX^j \\right)`
-
.. math::
<<\\vect{\\vect{\\vect{\\nabla }}}^2 h(\\muX,\\: \\vect{\\mu}_{X}),\\: \\uX - \\muX>,\\: \\uX - \\muX> = \\left( \\Tr{(\\uX^i - \\muX^i)}. \\left(\\frac{\\partial^2 y^k}{\\partial x^i \\partial x^k}\\right)_{\\ux = \\muX}. (\\uX^j - \\muX^j) \\right)_{ijk}
**Approximation at the order 1:**
Expectation:
.. math::
\\Expect{\\uY} \\approx \\vect{h}(\\muX)
Pay attention that :math:`\\Expect{\\uY}` is a vector. The :math:`k^\\textrm{th}`
component of this vector is equal to the :math:`k^\\textrm{th}` component of the
output vector computed by the model :math:`h` at the mean value.
:math:`\\Expect{\\uY}` is thus the computation of the model at mean.
Variance:
.. math::
\\Cov \\uY \\approx \\Tr{\\vect{\\vect{\\nabla}}}\\:\\vect{h}(\\muX).\\Cov \\uX.\\vect{\\vect{\\nabla}}\\:\\vect{h}(\\muX)
**Approximation at the order 2:**
Expectation:
.. math::
(\\Expect{\\uY})_k \\approx (\\vect{h}(\\muX))_k +
\\left(
\\sum_{i=1}^{n_X}\\frac{1}{2} (\\Cov \\uX)_{ii}.{(\\nabla^2\\:h(\\uX))}_{iik} +
\\sum_{i=1}^{n_X} \\sum_{j=1}^{i-1} (\\Cov X)_{ij}.{(\\nabla^2\\:h(\\uX))}_{ijk}
\\right)_k
Variance:
The decomposition of the variance at the order 2 is not implemented in the
standard version of OpenTURNS. It requires both the knowledge of higher order
derivatives of the model and the knowledge of moments of order strictly greater
than 2 of the PDF.
Examples
--------
>>> import openturns as ot
>>> ot.RandomGenerator.SetSeed(0)
>>> myFunc = ot.SymbolicFunction(['x1', 'x2', 'x3', 'x4'],
... ['(x1*x1+x2^3*x1)/(2*x3*x3+x4^4+1)', 'cos(x2*x2+x4)/(x1*x1+1+x3^4)'])
>>> R = ot.CorrelationMatrix(4)
>>> for i in range(4):
... R[i, i - 1] = 0.25
>>> distribution = ot.Normal([0.2]*4, [0.1, 0.2, 0.3, 0.4], R)
>>> # We create a distribution-based RandomVector
>>> X = ot.RandomVector(distribution)
>>> # We create a composite RandomVector Y from X and myFunc
>>> Y = ot.RandomVector(myFunc, X)
>>> # We create a Taylor expansion method to approximate moments
>>> myTaylorExpansionMoments = ot.TaylorExpansionMoments(Y)
>>> print(myTaylorExpansionMoments.getMeanFirstOrder())
[0.0384615,0.932544]
"""
__swig_setmethods__ = {}
for _s in [openturns.common.PersistentObject]:
__swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
__setattr__ = lambda self, name, value: _swig_setattr(self, TaylorExpansionMoments, name, value)
__swig_getmethods__ = {}
for _s in [openturns.common.PersistentObject]:
__swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
__getattr__ = lambda self, name: _swig_getattr(self, TaylorExpansionMoments, name)
def getClassName(self):
"""
Accessor to the object's name.
Returns
-------
class_name : str
The object class name (`object.__class__.__name__`).
"""
return _uncertainty.TaylorExpansionMoments_getClassName(self)
def __repr__(self):
return _uncertainty.TaylorExpansionMoments___repr__(self)
def getLimitStateVariable(self):
"""
Get the limit state variable.
Returns
-------
limitStateVariable : :class:`~openturns.RandomVector`
Limit state variable.
"""
return _uncertainty.TaylorExpansionMoments_getLimitStateVariable(self)
def getMeanFirstOrder(self):
"""
Get the approximation at the first order of the mean.
Returns
-------
mean : :class:`~openturns.Point`
Approximation at the first order of the mean of the random vector.
"""
return _uncertainty.TaylorExpansionMoments_getMeanFirstOrder(self)
def getMeanSecondOrder(self):
"""
Get the approximation at the second order of the mean.
Returns
-------
mean : :class:`~openturns.Point`
Approximation at the second order of the mean of the random vector
(it requires that the hessian of the Function has been defined).
"""
return _uncertainty.TaylorExpansionMoments_getMeanSecondOrder(self)
def getCovariance(self):
"""
Get the approximation at the first order of the covariance matrix.
Returns
-------
covariance : :class:`~openturns.CovarianceMatrix`
Approximation at the first order of the covariance matrix of the random
vector.
"""
return _uncertainty.TaylorExpansionMoments_getCovariance(self)
def getValueAtMean(self):
"""
Get the value of the function.
Returns
-------
value : :class:`~openturns.Point`
Value of the Function which defines the random vector at
the mean point of the input random vector.
"""
return _uncertainty.TaylorExpansionMoments_getValueAtMean(self)
def getGradientAtMean(self):
"""
Get the gradient of the function.
Returns
-------
gradient : :class:`~openturns.Matrix`
Gradient of the Function which defines the random vector at
the mean point of the input random vector.
"""
return _uncertainty.TaylorExpansionMoments_getGradientAtMean(self)
def getHessianAtMean(self):
"""
Get the hessian of the function.
Returns
-------
hessian : :class:`~openturns.SymmetricTensor`
Hessian of the Function which defines the random vector at
the mean point of the input random vector.
"""
return _uncertainty.TaylorExpansionMoments_getHessianAtMean(self)
def getImportanceFactors(self):
"""
Get the importance factors.
Returns
-------
factors : :class:`~openturns.Point`
Importance factors of the inputs : only when randVect is of dimension 1.
"""
return _uncertainty.TaylorExpansionMoments_getImportanceFactors(self)
def drawImportanceFactors(self):
"""
Draw the importance factors.
Returns
-------
graph : :class:`~openturns.Graph`
Graph containing the pie corresponding to the importance factors of the
probabilistic variables.
"""
return _uncertainty.TaylorExpansionMoments_drawImportanceFactors(self)
def __init__(self, *args):
this = _uncertainty.new_TaylorExpansionMoments(*args)
try:
self.this.append(this)
except __builtin__.Exception:
self.this = this
__swig_destroy__ = _uncertainty.delete_TaylorExpansionMoments
__del__ = lambda self: None
TaylorExpansionMoments_swigregister = _uncertainty.TaylorExpansionMoments_swigregister
TaylorExpansionMoments_swigregister(TaylorExpansionMoments)
class EfficientGlobalOptimization(openturns.optim.OptimizationAlgorithmImplementation):
"""
Efficient Global Optimization algorithm.
The EGO algorithm [Jones1998]_ is an adaptative optimization method based on
kriging.
An initial design of experiment is used to build a first metamodel.
At each iteration a new point that maximizes a criterion is chosen as
optimizer candidate.
The criterion uses a tradeoff between the metamodel value and the conditional
variance.
Then the new point is evaluated using the original model and the metamodel is
relearnt on the extended design of experiment.
Available constructors:
EfficientGlobalOptimization(*problem, krigingResult*)
Parameters
----------
problem : :class:`~openturns.OptimizationProblem`
The optimization problem to solve
optionally, a 2nd objective marginal can be used as noise
krigingResult : :class:`~openturns.KrigingResult`
The result of the meta-model on the first design of experiment
Notes
-----
Each point added to the metamodel design seeks to improve the current minimum.
We chose the point so as to maximize an improvement criterion based on the
metamodel.
.. math::
I(x_{new}) = max(f_{min} - Y_{new}, 0)
The default criteria is called EI (Expected Improvement) and aims at maximizing
the mean improvement:
.. math::
\\mathbb{E}\\left[I(x_{new})\\right] = \\mathbb{E}\\left[max(f_{min} - Y_{new}, 0)\\right]
This criterion is explicited using the kriging mean and variance:
.. math::
\\mathbb{E}\\left[I(x_{new})\\right] = (f_{min} - m_K(x_{new})) \\Phi\\left( \\frac{f_{min} - m_K(x_{new})}{s_K(x_{new})} \\right) + s_K(x_{new}) \\phi\\left( \\frac{f_{min} - m_K(x_{new})}{s_K(x_{new})} \\right)
An observation noise variance can be provided thanks to a 2nd objective marginal.
.. math:: Y_{obs} = Y(x) + \\sigma_{\\epsilon}(x) \\epsilon
In that case the AEI (Augmented Expected Improvement) formulation is used.
As we don't have access to the real minimum of the function anymore a quantile
of the kriging prediction is used, with the constant :math:`c`:
.. math:: u(x) = m_K(x) + c s_K(x)
This criterion is minimized over the design points:
.. math:: x_{min} = \\argmax_{x_i} (u(x_i))
The AEI criterion reads:
.. math::
AEI(x_{new}) = \\mathbb{E}\\left[max(m_K(x_{min}) - Y_{new}, 0)\\right] \\times \\left(1 - \\frac{\\sigma_{\\epsilon}(x_{new})}{\\sqrt{\\sigma_{\\epsilon}^2(x_{new})+s^2_K(x_{new})}} \\right)
with
.. math::
\\mathbb{E}\\left[max(m_K(x_{min}) - Y_{new}, 0)\\right] = (m_K(x_{min}) - m_K(x_{new})) \\Phi\\left( \\frac{m_K(x_{min}) - m_K(x_{new})}{s_K(x_{new})} \\right) + s_K(x_{new}) \\phi\\left( \\frac{m_K(x_{min}) - m_K(x_{new})}{s_K(x_{new})} \\right)
A less computationally expensive noise function can be provided through
:func:`setNoiseModel()` to evaluate :math:`\\sigma^2_{\\epsilon}(x)`
for the improvement criterion optimization, the objective being only used to
compute values and associated noise at design points.
By default the criteria is minimized using :class:`~openturns.MultiStart`
with starting points uniformly sampled in the optimization problem bounds,
see :func:`setMultiStartExperimentSize` and :func:`setMultiStartNumber`.
This behavior can be overridden by using another solver with :func:`setOptimizationAlgorithm`.
Examples
--------
>>> import openturns as ot
>>> ot.RandomGenerator.SetSeed(0)
>>> dim = 4
>>> model = ot.SymbolicFunction(['x1', 'x2', 'x3', 'x4'],
... ['x1*x1+x2^3*x1+x3+x4'])
>>> bounds = ot.Interval([-5.0] * dim, [5.0] * dim)
>>> problem = ot.OptimizationProblem()
>>> problem.setObjective(model)
>>> problem.setBounds(bounds)
>>> experiment = ot.Composite([0.0] * dim, [1.0, 2.0, 4.0])
>>> inputSample = experiment.generate()
>>> outputSample = model(inputSample)
>>> covarianceModel = ot.SquaredExponential([2.0] * dim, [0.1])
>>> basis = ot.ConstantBasisFactory(dim).build()
>>> kriging = ot.KrigingAlgorithm(inputSample, outputSample, covarianceModel, basis)
>>> kriging.run()
>>> algo = ot.EfficientGlobalOptimization(problem, kriging.getResult())
>>> algo.setMaximumIterationNumber(2)
>>> algo.run()
>>> result = algo.getResult()
"""
__swig_setmethods__ = {}
for _s in [openturns.optim.OptimizationAlgorithmImplementation]:
__swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
__setattr__ = lambda self, name, value: _swig_setattr(self, EfficientGlobalOptimization, name, value)
__swig_getmethods__ = {}
for _s in [openturns.optim.OptimizationAlgorithmImplementation]:
__swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
__getattr__ = lambda self, name: _swig_getattr(self, EfficientGlobalOptimization, name)
def getClassName(self):
"""
Accessor to the object's name.
Returns
-------
class_name : str
The object class name (`object.__class__.__name__`).
"""
return _uncertainty.EfficientGlobalOptimization_getClassName(self)
def __repr__(self):
return _uncertainty.EfficientGlobalOptimization___repr__(self)
def run(self):
"""Launch the optimization."""
return _uncertainty.EfficientGlobalOptimization_run(self)
def setOptimizationAlgorithm(self, solver):
"""
Expected improvement solver accessor.
Parameters
----------
solver : :class:`~openturns.OptimizationSolver`
The solver used to optimize the expected improvement
"""
return _uncertainty.EfficientGlobalOptimization_setOptimizationAlgorithm(self, solver)
def getOptimizationAlgorithm(self):
"""
Expected improvement solver accessor.
Returns
-------
solver : :class:`~openturns.OptimizationSolver`
The solver used to optimize the expected improvement
"""
return _uncertainty.EfficientGlobalOptimization_getOptimizationAlgorithm(self)
def getMultiStartExperimentSize(self):
"""
Size of the design to draw starting points.
Returns
-------
multiStartExperimentSize : int
The size of the Monte Carlo design from which to select the best starting
points.
"""
return _uncertainty.EfficientGlobalOptimization_getMultiStartExperimentSize(self)
def setMultiStartExperimentSize(self, multiStartExperimentSize):
"""
Size of the design to draw starting points.
Parameters
----------
multiStartExperimentSize : int
The size of the Monte Carlo design from which to select the best starting
points.
The default number can be tweaked with the
`EfficientGlobalOptimization-DefaultMultiStartExperimentSize` key from
:class:`~openturns.ResourceMap`.
"""
return _uncertainty.EfficientGlobalOptimization_setMultiStartExperimentSize(self, multiStartExperimentSize)
def getMultiStartNumber(self):
"""
Number of starting points for the criterion optimization.
Returns
-------
multiStartNumber : int
The number of starting points for the criterion optimization.
"""
return _uncertainty.EfficientGlobalOptimization_getMultiStartNumber(self)
def setMultiStartNumber(self, multiStartNumberSize):
"""
Number of starting points for the criterion optimization.
Parameters
----------
multiStartNumber : int
The number of starting points for the criterion optimization.
The default number can be tweaked with the
`EfficientGlobalOptimization-DefaultMultiStartNumber` key from
:class:`~openturns.ResourceMap`.
"""
return _uncertainty.EfficientGlobalOptimization_setMultiStartNumber(self, multiStartNumberSize)
def getParameterEstimationPeriod(self):
"""
Parameter estimation period accessor.
Returns
-------
period : int
The number of iterations between covariance parameters re-learn.
Default is 1 (each iteration). Can be set to 0 (never).
"""
return _uncertainty.EfficientGlobalOptimization_getParameterEstimationPeriod(self)
def setParameterEstimationPeriod(self, parameterEstimationPeriod):
"""
Parameter estimation period accessor.
Parameters
----------
period : int
The number of iterations between covariance parameters re-learn.
Default is 1 (each iteration). Can be set to 0 (never).
The default number can be tweaked with the
`EfficientGlobalOptimization-DefaultParameterEstimationPeriod` key from
:class:`~openturns.ResourceMap`.
"""
return _uncertainty.EfficientGlobalOptimization_setParameterEstimationPeriod(self, parameterEstimationPeriod)
def setImprovementFactor(self, improvementFactor):
"""
Improvement criterion factor accessor.
Parameters
----------
a : float
Used to define a stopping criterion on the improvement criterion:
:math:`I_{max} < \\alpha |Y_{min}|`
with :math:`I_{max}` the current maximum of the improvement
and :math:`Y_{min}` the current optimum.
"""
return _uncertainty.EfficientGlobalOptimization_setImprovementFactor(self, improvementFactor)
def getImprovementFactor(self):
"""
Improvement criterion factor accessor.
Returns
-------
a : float
Used to define a stopping criterion on the improvement criterion:
:math:`I_{max} < \\alpha |Y_{min}|`
with :math:`I_{max}` the current maximum of the improvement
and :math:`Y_{min}` the current optimum.
"""
return _uncertainty.EfficientGlobalOptimization_getImprovementFactor(self)
def setCorrelationLengthFactor(self, b):
"""
Correlation length stopping criterion factor accessor.
Parameters
----------
b : float
Used to define a stopping criterion on the minimum correlation length:
:math:`\\theta_i < \\frac{\\Delta_i^{min}}{b}`
with :math:`\\Delta^{min}` the minimum distance between design points.
"""
return _uncertainty.EfficientGlobalOptimization_setCorrelationLengthFactor(self, b)
def getCorrelationLengthFactor(self):
"""
Correlation length stopping criterion factor accessor.
Returns
-------
b : float
Used to define a stopping criterion on the minimum correlation length:
:math:`\\theta_i < \\frac{\\Delta_i^{min}}{b}`
with :math:`\\Delta^{min}` the minimum distance between design points.
"""
return _uncertainty.EfficientGlobalOptimization_getCorrelationLengthFactor(self)
def setAIETradeoff(self, c):
"""
AEI tradeoff constant accessor.
Parameters
----------
c : float
Used to define a quantile of the kriging prediction at the design points.
:math:`u(x)=m_K(x)+c*s_K(x)`
"""
return _uncertainty.EfficientGlobalOptimization_setAIETradeoff(self, c)
def getAIETradeoff(self):
"""
AEI tradeoff constant accessor.
Returns
-------
c : float
Used to define a quantile of the kriging prediction at the design points.
:math:`u(x)=m_K(x)+c*s_K(x)`
"""
return _uncertainty.EfficientGlobalOptimization_getAIETradeoff(self)
def setNoiseModel(self, noiseModel):
"""
Improvement noise model accessor.
Parameters
----------
noiseVariance : :class:`~openturns.Function`
The noise variance :math:`\\sigma^2_{\\epsilon}(x)` used for the AEI
criterion optimization only.
Of same input dimension than the objective and 1-d output.
"""
return _uncertainty.EfficientGlobalOptimization_setNoiseModel(self, noiseModel)
def getNoiseModel(self):
"""
Improvement noise model accessor.
Returns
-------
noiseVariance : :class:`~openturns.Function`
The noise variance :math:`\\sigma^2_{\\epsilon}(x)` used for the AEI
criterion optimization only.
Of same input dimension than the objective and 1-d output.
"""
return _uncertainty.EfficientGlobalOptimization_getNoiseModel(self)
def getExpectedImprovement(self):
"""
Expected improvement values.
Returns
-------
ei : :class:`~openturns.Sample`
The expected improvement optimal values.
"""
return _uncertainty.EfficientGlobalOptimization_getExpectedImprovement(self)
def __init__(self, *args):
this = _uncertainty.new_EfficientGlobalOptimization(*args)
try:
self.this.append(this)
except __builtin__.Exception:
self.this = this
__swig_destroy__ = _uncertainty.delete_EfficientGlobalOptimization
__del__ = lambda self: None
EfficientGlobalOptimization_swigregister = _uncertainty.EfficientGlobalOptimization_swigregister
EfficientGlobalOptimization_swigregister(EfficientGlobalOptimization)
class ANCOVA(_object):
"""
ANalysis of COVAriance method (ANCOVA).
Available constructor:
ANCOVA(*functionalChaosResult, correlatedInput*)
Parameters
----------
functionalChaosResult : :class:`~openturns.FunctionalChaosResult`
Functional chaos result approximating the model response with
uncorrelated inputs.
correlatedInput : 2-d sequence of float
Correlated inputs used to compute the real values of the output.
Its dimension must be equal to the number of inputs of the model.
Notes
-----
ANCOVA, a variance-based method described in [Caniou2012]_, is a generalization
of the ANOVA (ANalysis Of VAriance) decomposition for models with correlated
input parameters.
Let us consider a model :math:`Y = h(\\vect{X})` without making any hypothesis
on the dependence structure of :math:`\\vect{X} = \\{X^1, \\ldots, X^{n_X} \\}`, a
n_X-dimensional random vector. The covariance decomposition requires a functional
decomposition of the model. Thus the model response :math:`Y` is expanded as a
sum of functions of increasing dimension as follows:
.. math::
:label: model
h(\\vect{X}) = h_0 + \\sum_{u\\subseteq\\{1,\\dots,n_X\\}} h_u(X_u)
:math:`h_0` is the mean of :math:`Y`. Each function :math:`h_u` represents,
for any non empty set :math:`u\\subseteq\\{1, \\dots, n_X\\}`, the combined
contribution of the variables :math:`X_u` to :math:`Y`.
Using the properties of the covariance, the variance of :math:`Y` can be
decomposed into a variance part and a covariance part as follows:
.. math::
Var[Y]&= Cov\\left[h_0 + \\sum_{u\\subseteq\\{1,\\dots,n_X\\}} h_u(X_u), h_0 + \\sum_{u\\subseteq\\{1,\\dots,n_X\\}} h_u(X_u)\\right] \\\\
&= \\sum_{u\\subseteq\\{1,\\dots,n_X\\}} \\left[Var[h_u(X_u)] + Cov[h_u(X_u), \\sum_{v\\subseteq\\{1,\\dots,n_X\\}, v\\cap u=\\varnothing} h_v(X_v)]\\right]
This variance formula enables to define each total part of variance of
:math:`Y` due to :math:`X_u`, :math:`S_u`, as the sum of a *physical*
(or *uncorrelated*) part and a *correlated* part such as:
.. math::
S_u = \\frac{Cov[Y, h_u(X_u)]} {Var[Y]} = S_u^U + S_u^C
where :math:`S_u^U` is the uncorrelated part of variance of Y due to :math:`X_u`:
.. math::
S_u^U = \\frac{Var[h_u(X_u)]} {Var[Y]}
and :math:`S_u^C` is the contribution of the correlation of :math:`X_u` with the
other parameters:
.. math::
S_u^C = \\frac{Cov\\left[h_u(X_u), \\displaystyle \\sum_{v\\subseteq\\{1,\\dots,n_X\\}, v\\cap u=\\varnothing} h_v(X_v)\\right]}
{Var[Y]}
As the computational cost of the indices with the numerical model :math:`h`
can be very high, [Caniou2012]_ suggests to approximate the model response with
a polynomial chaos expansion:
.. math::
Y \\simeq \\hat{h} = \\sum_{j=0}^{P-1} \\alpha_j \\Psi_j(x)
However, for the sake of computational simplicity, the latter is constructed
considering *independent* components :math:`\\{X^1,\\dots,X^{n_X}\\}`. Thus the
chaos basis is not orthogonal with respect to the correlated inputs under
consideration, and it is only used as a metamodel to generate approximated
evaluations of the model response and its summands :eq:`model`.
The next step consists in identifying the component functions. For instance, for
:math:`u = \\{1\\}`:
.. math::
h_1(X_1) = \\sum_{\\alpha | \\alpha_1 \\neq 0, \\alpha_{i \\neq 1} = 0} y_{\\alpha} \\Psi_{\\alpha}(\\vect{X})
where :math:`\\alpha` is a set of degrees associated to the :math:`n_X` univariate
polynomial :math:`\\psi_i^{\\alpha_i}(X_i)`.
Then the model response :math:`Y` is evaluated using a sample
:math:`X=\\{x_k, k=1,\\dots,N\\}` of the correlated joint distribution. Finally,
the several indices are computed using the model response and its component
functions that have been identified on the polynomial chaos.
Examples
--------
>>> import openturns as ot
>>> ot.RandomGenerator.SetSeed(0)
>>> # Model and distribution definition
>>> model = ot.SymbolicFunction(['X1','X2'], ['4.*X1 + 5.*X2'])
>>> distribution = ot.ComposedDistribution([ot.Normal()] * 2)
>>> S = ot.CorrelationMatrix(2)
>>> S[1, 0] = 0.3
>>> R = ot.NormalCopula().GetCorrelationFromSpearmanCorrelation(S)
>>> CorrelatedInputDistribution = ot.ComposedDistribution([ot.Normal()] * 2, ot.NormalCopula(R))
>>> sample = CorrelatedInputDistribution.getSample(200)
>>> # Functional chaos computation
>>> productBasis = ot.OrthogonalProductPolynomialFactory([ot.HermiteFactory()] * 2, ot.EnumerateFunction(2))
>>> adaptiveStrategy = ot.FixedStrategy(productBasis, 15)
>>> projectionStrategy = ot.LeastSquaresStrategy(ot.MonteCarloExperiment(100))
>>> algo = ot.FunctionalChaosAlgorithm(model, distribution, adaptiveStrategy, projectionStrategy)
>>> algo.run()
>>> ancovaResult = ot.ANCOVA(algo.getResult(), sample)
>>> indices = ancovaResult.getIndices()
>>> print(indices)
[0.408398,0.591602]
>>> uncorrelatedIndices = ancovaResult.getUncorrelatedIndices()
>>> print(uncorrelatedIndices)
[0.284905,0.468108]
>>> # Get indices measuring the correlated effects
>>> print(indices - uncorrelatedIndices)
[0.123494,0.123494]
"""
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, ANCOVA, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, ANCOVA, name)
__repr__ = _swig_repr
def getUncorrelatedIndices(self, marginalIndex=0):
"""
Accessor to the ANCOVA indices measuring uncorrelated effects.
Parameters
----------
marginalIndex : int, :math:`0 \\leq i < n`, optional
Index of the model's marginal used to estimate the indices.
By default, marginalIndex is equal to 0.
Returns
-------
indices : :class:`~openturns.Point`
List of the ANCOVA indices measuring uncorrelated effects of the inputs.
The effects of the correlation are represented by the indices resulting
from the subtraction of the :meth:`getIndices` and
:meth:`getUncorrelatedIndices` lists.
"""
return _uncertainty.ANCOVA_getUncorrelatedIndices(self, marginalIndex)
def getIndices(self, marginalIndex=0):
"""
Accessor to the ANCOVA indices.
Parameters
----------
marginalIndex : int, :math:`0 \\leq i < n`, optional
Index of the model's marginal used to estimate the indices.
By default, marginalIndex is equal to 0.
Returns
-------
indices : :class:`~openturns.Point`
List of the ANCOVA indices measuring the contribution of the
input variables to the variance of the model. These indices are made up
of a *physical* part and a *correlated* part. The first one is obtained
thanks to :meth:`getUncorrelatedIndices`.
The effects of the correlation are represented by the indices resulting
from the subtraction of the :meth:`getIndices` and
:meth:`getUncorrelatedIndices` lists.
"""
return _uncertainty.ANCOVA_getIndices(self, marginalIndex)
def __init__(self, *args):
this = _uncertainty.new_ANCOVA(*args)
try:
self.this.append(this)
except __builtin__.Exception:
self.this = this
__swig_destroy__ = _uncertainty.delete_ANCOVA
__del__ = lambda self: None
ANCOVA_swigregister = _uncertainty.ANCOVA_swigregister
ANCOVA_swigregister(ANCOVA)
class FAST(_object):
"""
Fourier Amplitude Sensitivity Testing (FAST).
Available constructor:
FAST(*model, distribution, N, Nr=1, M=4*)
Parameters
----------
model : :class:`~openturns.Function`
Definition of the model to analyse.
distribution : :class:`~openturns.Distribution`
Contains the distributions of each model's input.
Its dimension must be equal to the number of inputs.
N : int, :math:`N > Nr`
Size of the sample from which the Fourier series are calculated.
It represents the length of the discretization of the s-space.
Nr : int, :math:`Nr \\geq 1`
Number of resamplings. The extended FAST method involves a part of
randomness in the computation of the indices. So it can be asked to
realize the procedure *Nr* times and then to calculate the
arithmetic means of the results over the *Nr* estimates.
M : int, :math:`0 < M < N`
Interference factor usually equal to 4 or higher.
It corresponds to the truncation level of the Fourier series, i.e. the
number of harmonics that are retained in the decomposition.
Notes
-----
FAST is a sensitivity analysis method which is based upon the ANOVA
decomposition of the variance of the model response :math:`y = f(\\vect{X})`,
the latter being represented by its Fourier expansion.
:math:`\\vect{X}=\\{X^1,\\dots,X^{n_X}\\}` is an input random vector of :math:`n_X`
independent components.
OpenTURNS implements the extended FAST method consisting in computing
alternately the first order and the total-effect indices of each input.
This approach, widely described in the paper by [Saltelli1999]_, relies upon a
Fourier decomposition of the model response. Its key idea is to recast this
representation as a function of a *scalar* parameter :math:`s`, by defining
parametric curves :math:`s \\mapsto x_i(s), i=1, \\dots, n_X` exploring the
support of the input random vector :math:`\\vect{X}`.
Then the Fourier expansion of the model response is:
.. math::
f(s) = \\sum_{k \\in \\Zset^N} A_k cos(ks) + B_k sin(ks)
where :math:`A_k` and :math:`B_k` are Fourier coefficients whose estimates are:
.. math::
\\hat{A}_k &= \\frac{1}{N} \\sum_{j=1}^N f(x_j^1,\\dots,x_j^{N_X}) cos\\left(\\frac{2k\\pi (j-1)}{N} \\right) \\quad , \\quad -\\frac{N}{2} \\leq k \\leq \\frac{N}{2} \\\\
\\hat{B}_k &= \\frac{1}{N} \\sum_{j=1}^N f(x_j^1,\\dots,x_j^{N_X}) sin\\left(\\frac{2k\\pi (j-1)}{N} \\right) \\quad , \\quad -\\frac{N}{2} \\leq k \\leq \\frac{N}{2}
The first order indices are estimated by:
.. math::
\\hat{S}_i = \\frac{\\hat{D}_i}{\\hat{D}}
= \\frac{\\sum_{p=1}^M(\\hat{A}_{p\\omega_i}^2 + \\hat{B}_{p\\omega_i}^2)^2}
{\\sum_{n=1}^{(N-1)/2}(\\hat{A}_n^2 + \\hat{B}_n^2)^2}
and the total order indices by:
.. math::
\\hat{T}_i = 1 - \\frac{\\hat{D}_{-i}}{\\hat{D}}
= 1 - \\frac{\\sum_{k=1}^{\\omega_i/2}(\\hat{A}_k^2 + \\hat{B}_k^2)^2}
{\\sum_{n=1}^{(N-1)/2}(\\hat{A}_n^2 + \\hat{B}_n^2)^2}
where :math:`\\hat{D}` is the total variance, :math:`\\hat{D}_i` the portion
of :math:`D` arising from the uncertainty of the :math:`i^{th}` input and
:math:`\\hat{D}_{-i}` is the part of the variance due to all the inputs
except the :math:`i^{th}` input.
:math:`N` is the size of the sample using to compute the Fourier series and
:math:`M` is the interference factor. *Saltelli et al.* (1999) recommanded to
set :math:`M` to a value in the range :math:`[4, 6]`.
:math:`\\{\\omega_i\\}, \\forall i=1, \\dots, n_X` is a set of integer frequencies
assigned to each input :math:`X^i`. The frequency associated with the input
for which the sensitivity indices are computed, is set to the maximum admissible
frequency satisfying the Nyquist criterion (which ensures to avoid aliasing effects):
.. math::
\\omega_i = \\frac{N - 1}{2M}
In the paper by Saltelli et al. (1999), for high sample size, it is suggested
that :math:`16 \\leq \\omega_i/N_r \\leq 64`.
Examples
--------
>>> import openturns as ot
>>> ot.RandomGenerator.SetSeed(0)
>>> formulaIshigami = ['sin(_pi*X1)+7*sin(_pi*X2)*sin(_pi*X2)+0.1*((_pi*X3)*(_pi*X3)*(_pi*X3)*(_pi*X3))*sin(_pi*X1)']
>>> modelIshigami = ot.SymbolicFunction(['X1', 'X2', 'X3'], formulaIshigami)
>>> distributions = ot.ComposedDistribution([ot.Uniform(-1.0, 1.0)] * 3)
>>> sensitivityAnalysis = ot.FAST(modelIshigami, distributions, 101)
>>> print(sensitivityAnalysis.getFirstOrderIndices())
[0.311097,0.441786,0.000396837]
"""
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, FAST, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, FAST, name)
__repr__ = _swig_repr
def getFirstOrderIndices(self, marginalIndex=0):
"""
Accessor to the first order indices.
Parameters
----------
marginalIndex : int, :math:`0 \\leq i < n`, optional
Index of the model's marginal used to estimate the indices.
By default, marginalIndex is equal to 0.
Returns
-------
indices : :class:`~openturns.Point`
List of the first order indices of all the inputs.
"""
return _uncertainty.FAST_getFirstOrderIndices(self, marginalIndex)
def getTotalOrderIndices(self, marginalIndex=0):
"""
Accessor to the total order indices.
Parameters
----------
marginalIndex : int, :math:`0 \\leq i < n`, optional
Index of the model's marginal used to estimate the indices.
By default, marginalIndex is equal to 0.
Returns
-------
indices : :class:`~openturns.Point`
List of the total-effect order indices of all the inputs.
"""
return _uncertainty.FAST_getTotalOrderIndices(self, marginalIndex)
def getFFTAlgorithm(self):
"""
Accessor to the FFT algorithm implementation.
Returns
-------
fft : a :class:`~openturns.FFT`
A FFT algorithm.
"""
return _uncertainty.FAST_getFFTAlgorithm(self)
def setFFTAlgorithm(self, fft):
"""
Accessor to the FFT algorithm implementation.
Parameters
----------
fft : a :class:`~openturns.FFT`
A FFT algorithm.
"""
return _uncertainty.FAST_setFFTAlgorithm(self, fft)
def setBlockSize(self, blockSize):
"""
Set the block size.
Parameters
----------
k : positive int
Size of each block the sample is splitted into, this allows to save space
while allowing multithreading, when available we recommend to use
the number of available CPUs, set by default to :math:`1`.
"""
return _uncertainty.FAST_setBlockSize(self, blockSize)
def getBlockSize(self):
"""
Get the block size.
Returns
-------
k : positive int
Size of each block the sample is splitted into, this allows to save space
while allowing multithreading, when available we recommend to use
the number of available CPUs, set by default to 1.
"""
return _uncertainty.FAST_getBlockSize(self)
def __init__(self, *args):
this = _uncertainty.new_FAST(*args)
try:
self.this.append(this)
except __builtin__.Exception:
self.this = this
__swig_destroy__ = _uncertainty.delete_FAST
__del__ = lambda self: None
FAST_swigregister = _uncertainty.FAST_swigregister
FAST_swigregister(FAST)
class SobolIndicesAlgorithmImplementation(openturns.common.PersistentObject):
"""
Sensitivity analysis.
Notes
-----
This method is concerned with analyzing the influence the random vector
:math:`\\vect{X} = \\left( X^1, \\ldots, X^{n_X} \\right)` has on a random variable
:math:`Y^k` which is being studied for uncertainty.
Here we attempt to evaluate the part of variance of :math:`Y^k` due to the different components :math:`X^i`.
We denote G the physical model such as :math:`\\vect{Y}=G(\\vect{X})`. Let us consider first the case where :math:`\\vect{Y}` is of dimension 1.
The objective here is to develop the variability of the random variable :math:`\\vect{Y}` as function of :math:`\\vect{X} = \\left( X^1, \\ldots, X^{n_X} \\right)`. Using the Hoeffding decomposition, we got:
.. math::
\\Var{\\vect{Y}} = \\sum_{i=1}^{n_X} V_i + \\sum_{i<j} V_{i,j} + \\sum_{i<k<j} V_{i,j,k} + \\cdots + V_{1,2,..,n_X}
where :
:math:`V_i = \\Var{\\Expect{ Y \\vert X_i}}` and :math:`V_{i,j} = \\Var{\\Expect{ Y \\vert X_i, X_j}} - V_i - V_j`. Using the previous decomposition, it follows that sensitivity indices are defined as follow:
.. math::
\\begin{array}{ccc}
S_i & = & \\frac{V_i}{\\Var{\\vect{Y}}} \\\\
S_{i,j} & = & \\frac{V_{i,j}}{\\Var{\\vect{Y}}}
\\end{array}
:math:`(S_i)` are the first order sensitivity indices and measure the impact of :math:`X_i` in the variance :math:`\\Var{\\vect{Y}}`,
:math:`(S_{i,j})` are the second order sensitivity indices and measure the impact of the interaction of :math:`X_i` and :math:`X_j` in the variance :math:`\\Var{\\vect{Y}}`.
When :math:`n_X >> 1`, we use total sensitivity indices :math:`ST_i`, which is defined as the sum of all indices that count the i-th variable:
.. math::
ST_i = 1 - \\frac{V_{-i}}{\\Var{\\vect{Y}}} = \\frac{VT_i}{\\Var{\\vect{Y}}}, \\forall\\ i\\in(1,2,...,n_X)
where :math:`V_{-i}` is the part of variance of :math:`\\Var{\\vect{Y}}` that do not countain the i-th variable.
|
In practice, to estimate these quantities, Sobol proposes to use numerical methods that rely on the two independent realizations of the random vector :math:`\\vect{X}`.
If we consider `A` and `B` two independent samples (of size `n`) of the previous random vector:
.. math::
A = \\left(
\\begin{array}{cccc}
a_{1,1} & a_{1,2} & \\cdots & a_{1, n_X} \\\\
a_{2,1} & a_{2,2} & \\cdots & a_{2, n_X} \\\\
\\vdots & \\vdots & \\ddots & \\vdots \\\\
a_{n,1} & a_{1,2} & \\cdots & a_{n, n_X}
\\end{array}
\\right), \\ B = \\left(
\\begin{array}{cccc}
b_{1,1} & b_{1,2} & \\cdots & b_{1, n_X} \\\\
b_{2,1} & b_{2,2} & \\cdots & b_{2, n_X} \\\\
\\vdots & \\vdots & \\vdots & \\vdots \\\\
b_{n,1} & b_{1,2} & \\cdots & b_{n, n_X}
\\end{array}
\\right)
Each line is a realization of the random vector. The purpose is to mix these two samples to get an estimate of the sensitivities.
`Sobol` method require respectively :math:`C^i` and :math:`D^{i,j}` sample designs for the evaluation of first order (respectively second order) sensitivity indices. These are defined as hereafter:
.. math::
C^i = \\left(
\\begin{array}{ccccc}
b_{1,1} & b_{1,2} & a_{1,i} & \\cdots & b_{1, n_X} \\\\
b_{2,1} & b_{2,2} & a_{2,i} & \\cdots & b_{2, n_X} \\\\
\\vdots & \\vdots & \\vdots & \\ddots & \\vdots \\\\
b_{n,1} & b_{1,2} & a_{n,i} & \\cdots & b_{n, n_X}
\\end{array}
\\right), \\ D^{i,j} = \\left(
\\begin{array}{ccccccc}
b_{1,1} & b_{1,2} & a_{1,i} & \\cdots & a_{1,j} & \\cdots & b_{1, n_X} \\\\
b_{2,1} & b_{2,2} & a_{2,i} & \\cdots & a_{2,j} & \\cdots & b_{2, n_X} \\\\
\\vdots & \\vdots & \\vdots & \\vdots & \\vdots & \\ddots & \\vdots \\\\
b_{n,1} & b_{n,2} & a_{n,i} & \\cdots & a_{n,j} & \\cdots & b_{n, n_X} \\\\
\\end{array}
\\right)
It follows that :math:`V_{i}` and :math:`V_{i,j}` terms are defined as follow:
.. math::
\\begin{array}{ccc}
V_i & = & \\frac{1}{n} \\sum_{k=1}^{n} G(A_k) G(C_k) - V_i - V_j - G_0^2 \\\\
V_{i,j} & = & \\frac{1}{n} \\sum_{k=1}^{n} G(A_k) G(D_k) - G_0^2 \\\\
G_0 & = & \\frac{1}{n} \\sum_{k=1}^{n} G(A_k)
\\end{array}
The implemented second order indices use this formula.
The major methods (`Saltelli`, `Jansen`, `Mauntz-Kucherenko`, `Martinez`) use the :math:`E^i` matrix to compute the indices (first order and total order). This matrix is defined as follows:
.. math::
E^i = \\left(
\\begin{array}{ccccc}
a_{1,1} & a_{1,2} & b_{1,i} & \\cdots & a_{1, n_X} \\\\
a_{2,1} & a_{2,2} & b_{2,i} & \\cdots & a_{2, n_X} \\\\
\\vdots & \\vdots & \\vdots & \\ddots & \\vdots \\\\
a_{n,1} & a_{1,2} & b_{n,i} & \\cdots & a_{n, n_X}
\\end{array}
\\right)
The formulas for the evaluation of the indices are given in each class documentation:
- :class:`~openturns.SaltelliSensitivityAlgorithm` for the `Saltelli` method,
- :class:`~openturns.JansenSensitivityAlgorithm` for the `Jansen` method,
- :class:`~openturns.MauntzKucherenkoSensitivityAlgorithm` for the `Mauntz-Kucherenko` method,
- :class:`~openturns.MartinezSensitivityAlgorithm` for the `Martinez` method
For multivariate outputs, aggregate indices can be computed thanks to the `getAggregatedFirstOrderIndices` and `getAggregatedTotalOrderIndices`. Such indices write as follow:
.. math::
\\begin{array}{ccc}
S_i & = & \\frac{ \\sum_{k=1}^{q} V_{i}^{(k)} }{ \\sum_{k=1}^{q} \\Var{Y_k} } \\\\
S_{i,j} & = & \\frac{ \\sum_{k=1}^{q} V_{i,j}^{(k)} }{ \\sum_{k=1}^{q} \\Var{Y_k} } \\\\
ST_i & = & \\frac{ \\sum_{k=1}^{q} VT_{i}^{(k)} }{ \\sum_{k=1}^{q} \\Var{Y_k} }
\\end{array}
Aggregated second order indices have not been implemented.
|
Note finally that evaluation of intervals for indices might be done for first and total order thanks to
the `getFirstOrderIndicesInterval` and `getTotalOrderIndicesInterval` methods. Default bootstrap size
and confidence level values are parametrized thanks to the resource map keys `SobolIndicesAlgorithm-BootstrapSize`
and `SobolIndicesAlgorithm-BootstrapConfidenceLevel`. Appropriate setters
might be called to change their values.
Also note that for numerical stability reasons the ouputs are centered before indices estimation:
.. math::
Y_k = Y_k - \\Eset(Y_k)
"""
__swig_setmethods__ = {}
for _s in [openturns.common.PersistentObject]:
__swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
__setattr__ = lambda self, name, value: _swig_setattr(self, SobolIndicesAlgorithmImplementation, name, value)
__swig_getmethods__ = {}
for _s in [openturns.common.PersistentObject]:
__swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
__getattr__ = lambda self, name: _swig_getattr(self, SobolIndicesAlgorithmImplementation, name)
def getClassName(self):
"""
Accessor to the object's name.
Returns
-------
class_name : str
The object class name (`object.__class__.__name__`).
"""
return _uncertainty.SobolIndicesAlgorithmImplementation_getClassName(self)
def getFirstOrderIndices(self, marginalIndex=0):
"""
Get first order Sobol indices.
Parameters
----------
i : int, optional
Index of the marginal of the function, equals to :math:`0` by default.
Returns
-------
indices : :class:`~openturns.Point`
Sequence containing first order Sobol indices.
"""
return _uncertainty.SobolIndicesAlgorithmImplementation_getFirstOrderIndices(self, marginalIndex)
def getFirstOrderIndicesInterval(self):
"""
Get interval for the merged first order Sobol indices.
Returns
-------
interval : :class:`~openturns.Interval`
Interval for first order Sobol indices for each component.
"""
return _uncertainty.SobolIndicesAlgorithmImplementation_getFirstOrderIndicesInterval(self)
def getSecondOrderIndices(self, marginalIndex=0):
"""
Get second order Sobol indices.
Parameters
----------
i : int, optional
Index of the marginal of the function, equals to :math:`0` by default.
Returns
-------
indices : :class:`~openturns.SymmetricMatrix`
Tensor containing second order Sobol indices.
"""
return _uncertainty.SobolIndicesAlgorithmImplementation_getSecondOrderIndices(self, marginalIndex)
def getTotalOrderIndices(self, marginalIndex=0):
"""
Get total order Sobol indices.
Parameters
----------
i : int, optional
Index of the marginal of the function, equals to :math:`0` by default.
Returns
-------
indices : :class:`~openturns.Point`
Sequence containing total order Sobol indices.
"""
return _uncertainty.SobolIndicesAlgorithmImplementation_getTotalOrderIndices(self, marginalIndex)
def getTotalOrderIndicesInterval(self):
"""
Get interval for the merged total order Sobol indices.
Returns
-------
interval : :class:`~openturns.Interval`
Interval for total order Sobol indices for each component.
"""
return _uncertainty.SobolIndicesAlgorithmImplementation_getTotalOrderIndicesInterval(self)
def getAggregatedFirstOrderIndices(self):
"""
Get the evaluation of merged first order Sobol indices.
Returns
-------
indices : :class:`~openturns.Point`
Sequence containing merged first order Sobol indices.
"""
return _uncertainty.SobolIndicesAlgorithmImplementation_getAggregatedFirstOrderIndices(self)
def getAggregatedTotalOrderIndices(self):
"""
Get the evaluation of merged total order Sobol indices.
Returns
-------
indices : :class:`~openturns.Point`
Sequence containing merged total order Sobol indices.
"""
return _uncertainty.SobolIndicesAlgorithmImplementation_getAggregatedTotalOrderIndices(self)
def getBootstrapSize(self):
"""
Get the number of bootstrap sampling size.
Returns
-------
bootstrapSize : int
Number of bootsrap sampling
"""
return _uncertainty.SobolIndicesAlgorithmImplementation_getBootstrapSize(self)
def setBootstrapSize(self, bootstrapSize):
"""
Set the number of bootstrap sampling size.
Default value is 0.
Parameters
----------
bootstrapSize : int
Number of bootsrap sampling
"""
return _uncertainty.SobolIndicesAlgorithmImplementation_setBootstrapSize(self, bootstrapSize)
def getBootstrapConfidenceLevel(self):
"""
Get the confidence interval level for bootstrap sampling.
Returns
-------
confidenceLevel : float
Confidence level for boostrap sampling
"""
return _uncertainty.SobolIndicesAlgorithmImplementation_getBootstrapConfidenceLevel(self)
def setBootstrapConfidenceLevel(self, confidenceLevel):
"""
Set the confidence interval level for bootstrap sampling.
Parameters
----------
confidenceLevel : float
Confidence level for boostrap sampling
"""
return _uncertainty.SobolIndicesAlgorithmImplementation_setBootstrapConfidenceLevel(self, confidenceLevel)
def __repr__(self):
return _uncertainty.SobolIndicesAlgorithmImplementation___repr__(self)
def __str__(self, *args):
return _uncertainty.SobolIndicesAlgorithmImplementation___str__(self, *args)
def Generate(*args):
"""
Generate the input design of experiment.
Usage:
SobolIndicesAlgorithmImplementation.Generate(*distribution, N, computeSecondOrder*)
SobolIndicesAlgorithmImplementation.Generate(*experiment, computeSecondOrder*)
Parameters
----------
distribution : :class:`~openturns.Distribution`
Input probabilistic model.
Should have independent copula
experiment : :class:`~openturns.WeightedExperiment`
Experiment for the generation of two independent samples.
N : int
Size of samples to generate
computeSecondOrder : bool
If True, design that will be generated contains elements for the evaluation
of second order indices.
Returns
-------
inputDesign : :class:`~openturns.Sample`
Full input design.
Notes
-----
Sensitivity algorithms rely on the definition of specific designs. The method generates design for the Saltelli method. Such designs could be used for both the Jansen, Martinez and MauntzKucherenko methods.
This precomputes such input designs using distribution or experiment by generating two independent samples and mixing columns of these ones to define the huge sample (design).
If computeSecondOrder is disabled, result design is of size :math:`N*(p+2)` where p is the input dimension.
If computeSecondOrder is enabled, design's size is :math:`N*(2p+2)`.
Model's answer could be evaluated outside the platform.
Examples
--------
>>> import openturns as ot
>>> ot.RandomGenerator.SetSeed(0)
>>> formula = ['sin(_pi*X1)+7*sin(_pi*X2)*sin(_pi*X2)+' + \\
... '0.1*((_pi*X3)*(_pi*X3)*(_pi*X3)*(_pi*X3))*sin(_pi*X1)']
>>> model = ot.SymbolicFunction(['X1', 'X2', 'X3'], formula)
>>> distribution = ot.ComposedDistribution([ot.Uniform(-1.0, 1.0)] * 3, \\
... ot.IndependentCopula(3))
>>> size = 100
>>> design = ot.SobolIndicesAlgorithmImplementation.Generate(distribution, size, True)
"""
return _uncertainty.SobolIndicesAlgorithmImplementation_Generate(*args)
Generate = staticmethod(Generate)
def DrawImportanceFactors(*args):
"""
Draw the importance factors.
:Available usages:
DrawImportanceFactors(*importanceFactors, title='Importance Factors'*)
DrawImportanceFactors(*values, names, title='Importance Factors'*)
Parameters
----------
importanceFactors : :class:`~openturns.PointWithDescription`
Sequence containing the importance factors with a description for each
component. The descriptions are used to build labels for the created Pie.
If they are not mentioned, default labels will be used.
values : sequence of float
Importance factors.
names : sequence of str
Variables' names used to build labels for the created Pie.
title : str
Title of the graph.
Returns
-------
Graph : :class:`~openturns.Graph`
A graph containing a :class:`~openturns.Pie` of the importance factors of
the variables.
"""
return _uncertainty.SobolIndicesAlgorithmImplementation_DrawImportanceFactors(*args)
DrawImportanceFactors = staticmethod(DrawImportanceFactors)
def draw(self, *args):
"""
Draw sensitivity indices.
Usage:
draw()
draw(*marginalIndex*)
With the first usage, draw the aggregated first and total order indices.
With the second usage, draw the first and total order indices of a specific marginal in case of vectorial output
Parameters
----------
marginalIndex: int
marginal of interest (case of second usage)
Returns
-------
Graph : :class:`~openturns.Graph`
A graph containing the aggregated first and total order indices.
Notes
-----
If number of bootstrap sampling is not 0, and confidence level associated > 0,
the graph includes confidence interval plots in the first usage.
"""
return _uncertainty.SobolIndicesAlgorithmImplementation_draw(self, *args)
def __init__(self, *args):
this = _uncertainty.new_SobolIndicesAlgorithmImplementation(*args)
try:
self.this.append(this)
except __builtin__.Exception:
self.this = this
__swig_destroy__ = _uncertainty.delete_SobolIndicesAlgorithmImplementation
__del__ = lambda self: None
SobolIndicesAlgorithmImplementation_swigregister = _uncertainty.SobolIndicesAlgorithmImplementation_swigregister
SobolIndicesAlgorithmImplementation_swigregister(SobolIndicesAlgorithmImplementation)
def SobolIndicesAlgorithmImplementation_Generate(*args):
"""
Generate the input design of experiment.
Usage:
SobolIndicesAlgorithmImplementation.Generate(*distribution, N, computeSecondOrder*)
SobolIndicesAlgorithmImplementation.Generate(*experiment, computeSecondOrder*)
Parameters
----------
distribution : :class:`~openturns.Distribution`
Input probabilistic model.
Should have independent copula
experiment : :class:`~openturns.WeightedExperiment`
Experiment for the generation of two independent samples.
N : int
Size of samples to generate
computeSecondOrder : bool
If True, design that will be generated contains elements for the evaluation
of second order indices.
Returns
-------
inputDesign : :class:`~openturns.Sample`
Full input design.
Notes
-----
Sensitivity algorithms rely on the definition of specific designs. The method generates design for the Saltelli method. Such designs could be used for both the Jansen, Martinez and MauntzKucherenko methods.
This precomputes such input designs using distribution or experiment by generating two independent samples and mixing columns of these ones to define the huge sample (design).
If computeSecondOrder is disabled, result design is of size :math:`N*(p+2)` where p is the input dimension.
If computeSecondOrder is enabled, design's size is :math:`N*(2p+2)`.
Model's answer could be evaluated outside the platform.
Examples
--------
>>> import openturns as ot
>>> ot.RandomGenerator.SetSeed(0)
>>> formula = ['sin(_pi*X1)+7*sin(_pi*X2)*sin(_pi*X2)+' + \\
... '0.1*((_pi*X3)*(_pi*X3)*(_pi*X3)*(_pi*X3))*sin(_pi*X1)']
>>> model = ot.SymbolicFunction(['X1', 'X2', 'X3'], formula)
>>> distribution = ot.ComposedDistribution([ot.Uniform(-1.0, 1.0)] * 3, \\
... ot.IndependentCopula(3))
>>> size = 100
>>> design = ot.SobolIndicesAlgorithmImplementation.Generate(distribution, size, True)
"""
return _uncertainty.SobolIndicesAlgorithmImplementation_Generate(*args)
def SobolIndicesAlgorithmImplementation_DrawImportanceFactors(*args):
"""
Draw the importance factors.
:Available usages:
DrawImportanceFactors(*importanceFactors, title='Importance Factors'*)
DrawImportanceFactors(*values, names, title='Importance Factors'*)
Parameters
----------
importanceFactors : :class:`~openturns.PointWithDescription`
Sequence containing the importance factors with a description for each
component. The descriptions are used to build labels for the created Pie.
If they are not mentioned, default labels will be used.
values : sequence of float
Importance factors.
names : sequence of str
Variables' names used to build labels for the created Pie.
title : str
Title of the graph.
Returns
-------
Graph : :class:`~openturns.Graph`
A graph containing a :class:`~openturns.Pie` of the importance factors of
the variables.
"""
return _uncertainty.SobolIndicesAlgorithmImplementation_DrawImportanceFactors(*args)
class SobolIndicesAlgorithmImplementationTypedInterfaceObject(openturns.common.InterfaceObject):
__swig_setmethods__ = {}
for _s in [openturns.common.InterfaceObject]:
__swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
__setattr__ = lambda self, name, value: _swig_setattr(self, SobolIndicesAlgorithmImplementationTypedInterfaceObject, name, value)
__swig_getmethods__ = {}
for _s in [openturns.common.InterfaceObject]:
__swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
__getattr__ = lambda self, name: _swig_getattr(self, SobolIndicesAlgorithmImplementationTypedInterfaceObject, name)
__repr__ = _swig_repr
def __init__(self, *args):
this = _uncertainty.new_SobolIndicesAlgorithmImplementationTypedInterfaceObject(*args)
try:
self.this.append(this)
except __builtin__.Exception:
self.this = this
def getImplementation(self, *args):
"""
Accessor to the underlying implementation.
Returns
-------
impl : Implementation
The implementation class.
"""
return _uncertainty.SobolIndicesAlgorithmImplementationTypedInterfaceObject_getImplementation(self, *args)
def setName(self, name):
"""
Accessor to the object's name.
Parameters
----------
name : str
The name of the object.
"""
return _uncertainty.SobolIndicesAlgorithmImplementationTypedInterfaceObject_setName(self, name)
def getName(self):
"""
Accessor to the object's name.
Returns
-------
name : str
The name of the object.
"""
return _uncertainty.SobolIndicesAlgorithmImplementationTypedInterfaceObject_getName(self)
def __eq__(self, other):
return _uncertainty.SobolIndicesAlgorithmImplementationTypedInterfaceObject___eq__(self, other)
__swig_destroy__ = _uncertainty.delete_SobolIndicesAlgorithmImplementationTypedInterfaceObject
__del__ = lambda self: None
SobolIndicesAlgorithmImplementationTypedInterfaceObject_swigregister = _uncertainty.SobolIndicesAlgorithmImplementationTypedInterfaceObject_swigregister
SobolIndicesAlgorithmImplementationTypedInterfaceObject_swigregister(SobolIndicesAlgorithmImplementationTypedInterfaceObject)
class SobolIndicesAlgorithm(SobolIndicesAlgorithmImplementationTypedInterfaceObject):
"""
Sensitivity analysis.
Notes
-----
This method is concerned with analyzing the influence the random vector
:math:`\\vect{X} = \\left( X^1, \\ldots, X^{n_X} \\right)` has on a random variable
:math:`Y^k` which is being studied for uncertainty.
Here we attempt to evaluate the part of variance of :math:`Y^k` due to the different components :math:`X^i`.
We denote G the physical model such as :math:`\\vect{Y}=G(\\vect{X})`. Let us consider first the case where :math:`\\vect{Y}` is of dimension 1.
The objective here is to develop the variability of the random variable :math:`\\vect{Y}` as function of :math:`\\vect{X} = \\left( X^1, \\ldots, X^{n_X} \\right)`. Using the Hoeffding decomposition, we got:
.. math::
\\Var{\\vect{Y}} = \\sum_{i=1}^{n_X} V_i + \\sum_{i<j} V_{i,j} + \\sum_{i<k<j} V_{i,j,k} + \\cdots + V_{1,2,..,n_X}
where :
:math:`V_i = \\Var{\\Expect{ Y \\vert X_i}}` and :math:`V_{i,j} = \\Var{\\Expect{ Y \\vert X_i, X_j}} - V_i - V_j`. Using the previous decomposition, it follows that sensitivity indices are defined as follow:
.. math::
\\begin{array}{ccc}
S_i & = & \\frac{V_i}{\\Var{\\vect{Y}}} \\\\
S_{i,j} & = & \\frac{V_{i,j}}{\\Var{\\vect{Y}}}
\\end{array}
:math:`(S_i)` are the first order sensitivity indices and measure the impact of :math:`X_i` in the variance :math:`\\Var{\\vect{Y}}`,
:math:`(S_{i,j})` are the second order sensitivity indices and measure the impact of the interaction of :math:`X_i` and :math:`X_j` in the variance :math:`\\Var{\\vect{Y}}`.
When :math:`n_X >> 1`, we use total sensitivity indices :math:`ST_i`, which is defined as the sum of all indices that count the i-th variable:
.. math::
ST_i = 1 - \\frac{V_{-i}}{\\Var{\\vect{Y}}} = \\frac{VT_i}{\\Var{\\vect{Y}}}, \\forall\\ i\\in(1,2,...,n_X)
where :math:`V_{-i}` is the part of variance of :math:`\\Var{\\vect{Y}}` that do not countain the i-th variable.
|
In practice, to estimate these quantities, Sobol proposes to use numerical methods that rely on the two independent realizations of the random vector :math:`\\vect{X}`.
If we consider `A` and `B` two independent samples (of size `n`) of the previous random vector:
.. math::
A = \\left(
\\begin{array}{cccc}
a_{1,1} & a_{1,2} & \\cdots & a_{1, n_X} \\\\
a_{2,1} & a_{2,2} & \\cdots & a_{2, n_X} \\\\
\\vdots & \\vdots & \\ddots & \\vdots \\\\
a_{n,1} & a_{1,2} & \\cdots & a_{n, n_X}
\\end{array}
\\right), \\ B = \\left(
\\begin{array}{cccc}
b_{1,1} & b_{1,2} & \\cdots & b_{1, n_X} \\\\
b_{2,1} & b_{2,2} & \\cdots & b_{2, n_X} \\\\
\\vdots & \\vdots & \\vdots & \\vdots \\\\
b_{n,1} & b_{1,2} & \\cdots & b_{n, n_X}
\\end{array}
\\right)
Each line is a realization of the random vector. The purpose is to mix these two samples to get an estimate of the sensitivities.
`Sobol` method require respectively :math:`C^i` and :math:`D^{i,j}` sample designs for the evaluation of first order (respectively second order) sensitivity indices. These are defined as hereafter:
.. math::
C^i = \\left(
\\begin{array}{ccccc}
b_{1,1} & b_{1,2} & a_{1,i} & \\cdots & b_{1, n_X} \\\\
b_{2,1} & b_{2,2} & a_{2,i} & \\cdots & b_{2, n_X} \\\\
\\vdots & \\vdots & \\vdots & \\ddots & \\vdots \\\\
b_{n,1} & b_{1,2} & a_{n,i} & \\cdots & b_{n, n_X}
\\end{array}
\\right), \\ D^{i,j} = \\left(
\\begin{array}{ccccccc}
b_{1,1} & b_{1,2} & a_{1,i} & \\cdots & a_{1,j} & \\cdots & b_{1, n_X} \\\\
b_{2,1} & b_{2,2} & a_{2,i} & \\cdots & a_{2,j} & \\cdots & b_{2, n_X} \\\\
\\vdots & \\vdots & \\vdots & \\vdots & \\vdots & \\ddots & \\vdots \\\\
b_{n,1} & b_{n,2} & a_{n,i} & \\cdots & a_{n,j} & \\cdots & b_{n, n_X} \\\\
\\end{array}
\\right)
It follows that :math:`V_{i}` and :math:`V_{i,j}` terms are defined as follow:
.. math::
\\begin{array}{ccc}
V_i & = & \\frac{1}{n} \\sum_{k=1}^{n} G(A_k) G(C_k) - V_i - V_j - G_0^2 \\\\
V_{i,j} & = & \\frac{1}{n} \\sum_{k=1}^{n} G(A_k) G(D_k) - G_0^2 \\\\
G_0 & = & \\frac{1}{n} \\sum_{k=1}^{n} G(A_k)
\\end{array}
The implemented second order indices use this formula.
The major methods (`Saltelli`, `Jansen`, `Mauntz-Kucherenko`, `Martinez`) use the :math:`E^i` matrix to compute the indices (first order and total order). This matrix is defined as follows:
.. math::
E^i = \\left(
\\begin{array}{ccccc}
a_{1,1} & a_{1,2} & b_{1,i} & \\cdots & a_{1, n_X} \\\\
a_{2,1} & a_{2,2} & b_{2,i} & \\cdots & a_{2, n_X} \\\\
\\vdots & \\vdots & \\vdots & \\ddots & \\vdots \\\\
a_{n,1} & a_{1,2} & b_{n,i} & \\cdots & a_{n, n_X}
\\end{array}
\\right)
The formulas for the evaluation of the indices are given in each class documentation:
- :class:`~openturns.SaltelliSensitivityAlgorithm` for the `Saltelli` method,
- :class:`~openturns.JansenSensitivityAlgorithm` for the `Jansen` method,
- :class:`~openturns.MauntzKucherenkoSensitivityAlgorithm` for the `Mauntz-Kucherenko` method,
- :class:`~openturns.MartinezSensitivityAlgorithm` for the `Martinez` method
For multivariate outputs, aggregate indices can be computed thanks to the `getAggregatedFirstOrderIndices` and `getAggregatedTotalOrderIndices`. Such indices write as follow:
.. math::
\\begin{array}{ccc}
S_i & = & \\frac{ \\sum_{k=1}^{q} V_{i}^{(k)} }{ \\sum_{k=1}^{q} \\Var{Y_k} } \\\\
S_{i,j} & = & \\frac{ \\sum_{k=1}^{q} V_{i,j}^{(k)} }{ \\sum_{k=1}^{q} \\Var{Y_k} } \\\\
ST_i & = & \\frac{ \\sum_{k=1}^{q} VT_{i}^{(k)} }{ \\sum_{k=1}^{q} \\Var{Y_k} }
\\end{array}
Aggregated second order indices have not been implemented.
|
Note finally that evaluation of intervals for indices might be done for first and total order thanks to
the `getFirstOrderIndicesInterval` and `getTotalOrderIndicesInterval` methods. Default bootstrap size
and confidence level values are parametrized thanks to the resource map keys `SobolIndicesAlgorithm-BootstrapSize`
and `SobolIndicesAlgorithm-BootstrapConfidenceLevel`. Appropriate setters
might be called to change their values.
Also note that for numerical stability reasons the ouputs are centered before indices estimation:
.. math::
Y_k = Y_k - \\Eset(Y_k)
"""
__swig_setmethods__ = {}
for _s in [SobolIndicesAlgorithmImplementationTypedInterfaceObject]:
__swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
__setattr__ = lambda self, name, value: _swig_setattr(self, SobolIndicesAlgorithm, name, value)
__swig_getmethods__ = {}
for _s in [SobolIndicesAlgorithmImplementationTypedInterfaceObject]:
__swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
__getattr__ = lambda self, name: _swig_getattr(self, SobolIndicesAlgorithm, name)
def getClassName(self):
"""
Accessor to the object's name.
Returns
-------
class_name : str
The object class name (`object.__class__.__name__`).
"""
return _uncertainty.SobolIndicesAlgorithm_getClassName(self)
def getFirstOrderIndices(self, marginalIndex=0):
"""
Get first order Sobol indices.
Parameters
----------
i : int, optional
Index of the marginal of the function, equals to :math:`0` by default.
Returns
-------
indices : :class:`~openturns.Point`
Sequence containing first order Sobol indices.
"""
return _uncertainty.SobolIndicesAlgorithm_getFirstOrderIndices(self, marginalIndex)
def getFirstOrderIndicesInterval(self):
"""
Get interval for the merged first order Sobol indices.
Returns
-------
interval : :class:`~openturns.Interval`
Interval for first order Sobol indices for each component.
"""
return _uncertainty.SobolIndicesAlgorithm_getFirstOrderIndicesInterval(self)
def getSecondOrderIndices(self, marginalIndex=0):
"""
Get second order Sobol indices.
Parameters
----------
i : int, optional
Index of the marginal of the function, equals to :math:`0` by default.
Returns
-------
indices : :class:`~openturns.SymmetricMatrix`
Tensor containing second order Sobol indices.
"""
return _uncertainty.SobolIndicesAlgorithm_getSecondOrderIndices(self, marginalIndex)
def getTotalOrderIndices(self, marginalIndex=0):
"""
Get total order Sobol indices.
Parameters
----------
i : int, optional
Index of the marginal of the function, equals to :math:`0` by default.
Returns
-------
indices : :class:`~openturns.Point`
Sequence containing total order Sobol indices.
"""
return _uncertainty.SobolIndicesAlgorithm_getTotalOrderIndices(self, marginalIndex)
def getTotalOrderIndicesInterval(self):
"""
Get interval for the merged total order Sobol indices.
Returns
-------
interval : :class:`~openturns.Interval`
Interval for total order Sobol indices for each component.
"""
return _uncertainty.SobolIndicesAlgorithm_getTotalOrderIndicesInterval(self)
def getAggregatedFirstOrderIndices(self):
"""
Get the evaluation of merged first order Sobol indices.
Returns
-------
indices : :class:`~openturns.Point`
Sequence containing merged first order Sobol indices.
"""
return _uncertainty.SobolIndicesAlgorithm_getAggregatedFirstOrderIndices(self)
def getAggregatedTotalOrderIndices(self):
"""
Get the evaluation of merged total order Sobol indices.
Returns
-------
indices : :class:`~openturns.Point`
Sequence containing merged total order Sobol indices.
"""
return _uncertainty.SobolIndicesAlgorithm_getAggregatedTotalOrderIndices(self)
def getBootstrapSize(self):
"""
Get the number of bootstrap sampling size.
Returns
-------
bootstrapSize : int
Number of bootsrap sampling
"""
return _uncertainty.SobolIndicesAlgorithm_getBootstrapSize(self)
def setBootstrapSize(self, bootstrapSize):
"""
Set the number of bootstrap sampling size.
Default value is 0.
Parameters
----------
bootstrapSize : int
Number of bootsrap sampling
"""
return _uncertainty.SobolIndicesAlgorithm_setBootstrapSize(self, bootstrapSize)
def getBootstrapConfidenceLevel(self):
"""
Get the confidence interval level for bootstrap sampling.
Returns
-------
confidenceLevel : float
Confidence level for boostrap sampling
"""
return _uncertainty.SobolIndicesAlgorithm_getBootstrapConfidenceLevel(self)
def setBootstrapConfidenceLevel(self, confidenceLevel):
"""
Set the confidence interval level for bootstrap sampling.
Parameters
----------
confidenceLevel : float
Confidence level for boostrap sampling
"""
return _uncertainty.SobolIndicesAlgorithm_setBootstrapConfidenceLevel(self, confidenceLevel)
def draw(self, *args):
"""
Draw sensitivity indices.
Usage:
draw()
draw(*marginalIndex*)
With the first usage, draw the aggregated first and total order indices.
With the second usage, draw the first and total order indices of a specific marginal in case of vectorial output
Parameters
----------
marginalIndex: int
marginal of interest (case of second usage)
Returns
-------
Graph : :class:`~openturns.Graph`
A graph containing the aggregated first and total order indices.
Notes
-----
If number of bootstrap sampling is not 0, and confidence level associated > 0,
the graph includes confidence interval plots in the first usage.
"""
return _uncertainty.SobolIndicesAlgorithm_draw(self, *args)
def __repr__(self):
return _uncertainty.SobolIndicesAlgorithm___repr__(self)
def __str__(self, *args):
return _uncertainty.SobolIndicesAlgorithm___str__(self, *args)
def __init__(self, *args):
this = _uncertainty.new_SobolIndicesAlgorithm(*args)
try:
self.this.append(this)
except __builtin__.Exception:
self.this = this
__swig_destroy__ = _uncertainty.delete_SobolIndicesAlgorithm
__del__ = lambda self: None
SobolIndicesAlgorithm_swigregister = _uncertainty.SobolIndicesAlgorithm_swigregister
SobolIndicesAlgorithm_swigregister(SobolIndicesAlgorithm)
class MartinezSensitivityAlgorithm(SobolIndicesAlgorithmImplementation):
"""
Sensitivity analysis using Martinez method
Available constructors:
MartinezSensitivityAlgorithm(*inputDesign, outputDesign, N, computeSecondOrder*)
MartinezSensitivityAlgorithm(*distribution, N, model, computeSecondOrder*)
MartinezSensitivityAlgorithm(*experiment, model, computeSecondOrder*)
Parameters
----------
inputDesign : :class:`~openturns.Sample`
Design for the evaluation of sensitivity indices, obtained
thanks to the SobolIndicesAlgorithmImplementation.Generate method
outputDesign : :class:`~openturns.Sample`
Design for the evaluation of sensitivity indices, obtained as the evaluation
of a Function (model) on the previous inputDesign
distribution : :class:`~openturns.Distribution`
Input probabilistic model.
Should have independent copula
experiment : :class:`~openturns.WeightedExperiment`
Experiment for the generation of two independent samples.
N : int
Size of samples to generate
computeSecondOrder : bool
If True, design that will be generated contains elements for the evaluation
of second order indices.
Notes
-----
This class is concerned with analyzing the influence the random vector
:math:`\\vect{X} = \\left( X^1, \\ldots, X^{n_X} \\right)` has on a random variable
:math:`Y^k` which is being studied for uncertainty, by using the [Martinez2011]_
method for the evaluation of both first and total order indices.
These last ones are respectively given as follows:
.. math::
\\begin{array}{ccc}
\\hat{S_i} & = & \\rho_n(G(B), G(E^i)) \\\\
\\hat{ST_i} & = & 1 - \\rho_n(G(A), G(E^i)) \\\\
\\end{array}
where :math:`\\rho_n` is the empirical correlation defined by:
.. math::
\\rho_n(X, Y) = \\frac{\\Cov{X,Y}}{\\sqrt{\\Var{X} \\Var{Y}}}
The class provides also the evaluation of asymptotic confidence interval for first
and total order indices, relying on the Fisher transformation.
This could be performed for gaussian output data. The
`MartinezSensitivityAlgorithm-UseAsmpytoticInterval` resource map key should
be fixed to True in that case.
See also
--------
SobolIndicesAlgorithm
Examples
--------
>>> import openturns as ot
>>> ot.RandomGenerator.SetSeed(0)
>>> formula = ['sin(_pi*X1)+7*sin(_pi*X2)*sin(_pi*X2)+' + \\
... '0.1*((_pi*X3)*(_pi*X3)*(_pi*X3)*(_pi*X3))*sin(_pi*X1)']
>>> model = ot.SymbolicFunction(['X1', 'X2', 'X3'], formula)
>>> distribution = ot.ComposedDistribution([ot.Uniform(-1.0, 1.0)] * 3, \\
... ot.IndependentCopula(3))
>>> # Define designs to pre-compute
>>> size = 100
>>> inputDesign = ot.SobolIndicesAlgorithmImplementation.Generate(distribution, size, True)
>>> outputDesign = model(inputDesign)
>>> # sensitivity analysis algorithm
>>> sensitivityAnalysis = ot.MartinezSensitivityAlgorithm(inputDesign, outputDesign, size)
>>> print(sensitivityAnalysis.getFirstOrderIndices())
[0.30449,0.448506,-0.0711394]
"""
__swig_setmethods__ = {}
for _s in [SobolIndicesAlgorithmImplementation]:
__swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
__setattr__ = lambda self, name, value: _swig_setattr(self, MartinezSensitivityAlgorithm, name, value)
__swig_getmethods__ = {}
for _s in [SobolIndicesAlgorithmImplementation]:
__swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
__getattr__ = lambda self, name: _swig_getattr(self, MartinezSensitivityAlgorithm, name)
def getClassName(self):
"""
Accessor to the object's name.
Returns
-------
class_name : str
The object class name (`object.__class__.__name__`).
"""
return _uncertainty.MartinezSensitivityAlgorithm_getClassName(self)
def __repr__(self):
return _uncertainty.MartinezSensitivityAlgorithm___repr__(self)
def getFirstOrderIndicesInterval(self):
"""
Get interval for the merged first order Sobol indices.
Returns
-------
interval : :class:`~openturns.Interval`
Interval for first order Sobol indices for each component.
"""
return _uncertainty.MartinezSensitivityAlgorithm_getFirstOrderIndicesInterval(self)
def getTotalOrderIndicesInterval(self):
"""
Get interval for the merged total order Sobol indices.
Returns
-------
interval : :class:`~openturns.Interval`
Interval for total order Sobol indices for each component.
"""
return _uncertainty.MartinezSensitivityAlgorithm_getTotalOrderIndicesInterval(self)
def __init__(self, *args):
this = _uncertainty.new_MartinezSensitivityAlgorithm(*args)
try:
self.this.append(this)
except __builtin__.Exception:
self.this = this
__swig_destroy__ = _uncertainty.delete_MartinezSensitivityAlgorithm
__del__ = lambda self: None
MartinezSensitivityAlgorithm_swigregister = _uncertainty.MartinezSensitivityAlgorithm_swigregister
MartinezSensitivityAlgorithm_swigregister(MartinezSensitivityAlgorithm)
class SaltelliSensitivityAlgorithm(SobolIndicesAlgorithmImplementation):
"""
Sensitivity analysis using Saltelli method.
Available constructors:
SaltelliSensitivityAlgorithm(*inputDesign, outputDesign, N, computeSecondOrder*)
SaltelliSensitivityAlgorithm(*distribution, N, model, computeSecondOrder*)
SaltelliSensitivityAlgorithm(*experiment, model, computeSecondOrder*)
Parameters
----------
inputDesign : :class:`~openturns.Sample`
Design for the evaluation of sensitivity indices, obtained
thanks to the SobolIndicesAlgorithmImplementation.Generate method
outputDesign : :class:`~openturns.Sample`
Design for the evaluation of sensitivity indices, obtained as the evaluation
of a Function (model) on the previous inputDesign
distribution : :class:`~openturns.Distribution`
Input probabilistic model.
Should have independent copula
experiment : :class:`~openturns.WeightedExperiment`
Experiment for the generation of two independent samples.
N : int
Size of samples to generate
computeSecondOrder : bool
If True, design that will be generated contains elements for the evaluation
of second order indices.
Notes
-----
This class is concerned with analyzing the influence the random vector
:math:`\\vect{X} = \\left( X^1, \\ldots, X^{n_X} \\right)` has on a random variable
:math:`Y^k` which is being studied for uncertainty, by using the [Saltelli2002]_
method for the evaluation of both first and total order indices.
These last ones are respectively given as follows:
.. math::
\\begin{array}{ccc}
\\hat{V_i} & = & \\frac{1}{n}\\sum_{k=1}^{n} G(B_k) G(E_k) - G_0^2 \\\\
\\hat{V_{-i}} & = & \\frac{1}{n}\\sum_{k=1}^{n} G(A_k) G(E_k) - G_0^2
\\end{array}
See also
--------
SobolIndicesAlgorithm
Examples
--------
>>> import openturns as ot
>>> ot.RandomGenerator.SetSeed(0)
>>> formula = ['sin(_pi*X1)+7*sin(_pi*X2)*sin(_pi*X2)+' + \\
... '0.1*((_pi*X3)*(_pi*X3)*(_pi*X3)*(_pi*X3))*sin(_pi*X1)']
>>> model = ot.SymbolicFunction(['X1', 'X2', 'X3'], formula)
>>> distribution = ot.ComposedDistribution([ot.Uniform(-1.0, 1.0)] * 3, \\
... ot.IndependentCopula(3))
>>> # Define designs to pre-compute
>>> size = 100
>>> inputDesign = ot.SobolIndicesAlgorithmImplementation.Generate(distribution, size, True)
>>> outputDesign = model(inputDesign)
>>> # sensitivity analysis algorithm
>>> sensitivityAnalysis = ot.SaltelliSensitivityAlgorithm(inputDesign, outputDesign, size)
>>> print(sensitivityAnalysis.getFirstOrderIndices())
[0.182857,0.357745,-0.128457]
"""
__swig_setmethods__ = {}
for _s in [SobolIndicesAlgorithmImplementation]:
__swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
__setattr__ = lambda self, name, value: _swig_setattr(self, SaltelliSensitivityAlgorithm, name, value)
__swig_getmethods__ = {}
for _s in [SobolIndicesAlgorithmImplementation]:
__swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
__getattr__ = lambda self, name: _swig_getattr(self, SaltelliSensitivityAlgorithm, name)
def getClassName(self):
"""
Accessor to the object's name.
Returns
-------
class_name : str
The object class name (`object.__class__.__name__`).
"""
return _uncertainty.SaltelliSensitivityAlgorithm_getClassName(self)
def __repr__(self):
return _uncertainty.SaltelliSensitivityAlgorithm___repr__(self)
def __init__(self, *args):
this = _uncertainty.new_SaltelliSensitivityAlgorithm(*args)
try:
self.this.append(this)
except __builtin__.Exception:
self.this = this
__swig_destroy__ = _uncertainty.delete_SaltelliSensitivityAlgorithm
__del__ = lambda self: None
SaltelliSensitivityAlgorithm_swigregister = _uncertainty.SaltelliSensitivityAlgorithm_swigregister
SaltelliSensitivityAlgorithm_swigregister(SaltelliSensitivityAlgorithm)
class JansenSensitivityAlgorithm(SobolIndicesAlgorithmImplementation):
"""
Sensitivity analysis using Jansen method.
Available constructors:
JansenSensitivityAlgorithm(*inputDesign, outputDesign, N, computeSecondOrder*)
JansenSensitivityAlgorithm(*distribution, N, model, computeSecondOrder*)
JansenSensitivityAlgorithm(*experiment, model, computeSecondOrder*)
Parameters
----------
inputDesign : :class:`~openturns.Sample`
Design for the evaluation of sensitivity indices, obtained
thanks to the SobolIndicesAlgorithmImplementation.Generate method
outputDesign : :class:`~openturns.Sample`
Design for the evaluation of sensitivity indices, obtained as the evaluation
of a Function (model) on the previous inputDesign
distribution : :class:`~openturns.Distribution`
Input probabilistic model.
Should have independent copula
experiment : :class:`~openturns.WeightedExperiment`
Experiment for the generation of two independent samples.
N : int
Size of samples to generate
computeSecondOrder : bool
If True, design that will be generated contains elements for the evaluation
of second order indices.
Notes
-----
This class is concerned with analyzing the influence the random vector
:math:`\\vect{X} = \\left( X^1, \\ldots, X^{n_X} \\right)` has on a random variable
:math:`Y^k` which is being studied for uncertainty, by using the [Jansen1999]_
method for the evaluation of both first and total order indices.
These last ones are respectively given as follows:
.. math::
\\begin{array}{ccc}
\\hat{V_i} & = & \\frac{1}{n} \\sum_{k=1}^{n} \\left(G(A_k)^2 - G_0^2\\right) - \\frac{1}{2n} \\sum_{k=1}^{n} \\left( G(E_k) - G(B_k) \\right)^2 \\\\
\\hat{VT_{i}} & = & \\frac{1}{n} \\sum_{k=1}^{n} \\left( G(A_k) - G(E_k) \\right)^2
\\end{array}
See also
--------
SobolIndicesAlgorithm
Examples
--------
>>> import openturns as ot
>>> ot.RandomGenerator.SetSeed(0)
>>> formula = ['sin(_pi*X1)+7*sin(_pi*X2)*sin(_pi*X2)+' + \\
... '0.1*((_pi*X3)*(_pi*X3)*(_pi*X3)*(_pi*X3))*sin(_pi*X1)']
>>> model = ot.SymbolicFunction(['X1', 'X2', 'X3'], formula)
>>> distribution = ot.ComposedDistribution([ot.Uniform(-1.0, 1.0)] * 3, \\
... ot.IndependentCopula(3))
>>> # Define designs to pre-compute
>>> size = 100
>>> inputDesign = ot.SobolIndicesAlgorithmImplementation.Generate(distribution, size, True)
>>> outputDesign = model(inputDesign)
>>> # sensitivity analysis algorithm
>>> sensitivityAnalysis = ot.JansenSensitivityAlgorithm(inputDesign, outputDesign, size)
>>> print(sensitivityAnalysis.getFirstOrderIndices())
[0.403551,0.487879,0.140996]
"""
__swig_setmethods__ = {}
for _s in [SobolIndicesAlgorithmImplementation]:
__swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
__setattr__ = lambda self, name, value: _swig_setattr(self, JansenSensitivityAlgorithm, name, value)
__swig_getmethods__ = {}
for _s in [SobolIndicesAlgorithmImplementation]:
__swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
__getattr__ = lambda self, name: _swig_getattr(self, JansenSensitivityAlgorithm, name)
def getClassName(self):
"""
Accessor to the object's name.
Returns
-------
class_name : str
The object class name (`object.__class__.__name__`).
"""
return _uncertainty.JansenSensitivityAlgorithm_getClassName(self)
def __repr__(self):
return _uncertainty.JansenSensitivityAlgorithm___repr__(self)
def __init__(self, *args):
this = _uncertainty.new_JansenSensitivityAlgorithm(*args)
try:
self.this.append(this)
except __builtin__.Exception:
self.this = this
__swig_destroy__ = _uncertainty.delete_JansenSensitivityAlgorithm
__del__ = lambda self: None
JansenSensitivityAlgorithm_swigregister = _uncertainty.JansenSensitivityAlgorithm_swigregister
JansenSensitivityAlgorithm_swigregister(JansenSensitivityAlgorithm)
class MauntzKucherenkoSensitivityAlgorithm(SobolIndicesAlgorithmImplementation):
"""
Sensitivity analysis using MauntzKucherenko method.
Available constructors:
MauntzKucherenkoSensitivityAlgorithm(*inputDesign, outputDesign, N, computeSecondOrder*)
MauntzKucherenkoSensitivityAlgorithm(*distribution, N, model, computeSecondOrder*)
MauntzKucherenkoSensitivityAlgorithm(*experiment, model, computeSecondOrder*)
Parameters
----------
inputDesign : :class:`~openturns.Sample`
Design for the evaluation of sensitivity indices, obtained
thanks to the SobolIndicesAlgorithmImplementation.Generate method
outputDesign : :class:`~openturns.Sample`
Design for the evaluation of sensitivity indices, obtained as the evaluation
of a Function (model) on the previous inputDesign
distribution : :class:`~openturns.Distribution`
Input probabilistic model.
Should have independent copula
experiment : :class:`~openturns.WeightedExperiment`
Experiment for the generation of two independent samples.
N : int
Size of samples to generate
computeSecondOrder : bool
If True, design that will be generated contains elements for the evaluation
of second order indices.
Notes
-----
This class is concerned with analyzing the influence the random vector
:math:`\\vect{X} = \\left( X^1, \\ldots, X^{n_X} \\right)` has on a random variable
:math:`Y^k` which is being studied for uncertainty, by using the [Sobol2007]_
method for the evaluation of both first and total order indices.
These last ones are respectively given as follows:
.. math::
\\begin{array}{ccc}
\\hat{V_i} & = & \\frac{1}{n} \\sum_{k=1}^{n} G(B_k) \\left( G(E_k) - G(A_k) \\right) \\\\
\\hat{VT_{i}} & = & \\frac{1}{n} \\sum_{k=1}^{n} G(A_k) \\left( G(A_k) - G(E_k) \\right)
\\end{array}
See also
--------
SobolIndicesAlgorithm
Examples
--------
>>> import openturns as ot
>>> ot.RandomGenerator.SetSeed(0)
>>> formula = ['sin(_pi*X1)+7*sin(_pi*X2)*sin(_pi*X2)+' + \\
... '0.1*((_pi*X3)*(_pi*X3)*(_pi*X3)*(_pi*X3))*sin(_pi*X1)']
>>> model = ot.SymbolicFunction(['X1', 'X2', 'X3'], formula)
>>> distribution = ot.ComposedDistribution([ot.Uniform(-1.0, 1.0)] * 3, \\
... ot.IndependentCopula(3))
>>> # Define designs to pre-compute
>>> size = 100
>>> inputDesign = ot.SobolIndicesAlgorithmImplementation.Generate(distribution, size, True)
>>> outputDesign = model(inputDesign)
>>> # sensitivity analysis algorithm
>>> sensitivityAnalysis = ot.MauntzKucherenkoSensitivityAlgorithm(inputDesign, outputDesign, size)
>>> print(sensitivityAnalysis.getFirstOrderIndices())
[0.182219,0.357106,-0.129096]
"""
__swig_setmethods__ = {}
for _s in [SobolIndicesAlgorithmImplementation]:
__swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
__setattr__ = lambda self, name, value: _swig_setattr(self, MauntzKucherenkoSensitivityAlgorithm, name, value)
__swig_getmethods__ = {}
for _s in [SobolIndicesAlgorithmImplementation]:
__swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
__getattr__ = lambda self, name: _swig_getattr(self, MauntzKucherenkoSensitivityAlgorithm, name)
def getClassName(self):
"""
Accessor to the object's name.
Returns
-------
class_name : str
The object class name (`object.__class__.__name__`).
"""
return _uncertainty.MauntzKucherenkoSensitivityAlgorithm_getClassName(self)
def __repr__(self):
return _uncertainty.MauntzKucherenkoSensitivityAlgorithm___repr__(self)
def __init__(self, *args):
this = _uncertainty.new_MauntzKucherenkoSensitivityAlgorithm(*args)
try:
self.this.append(this)
except __builtin__.Exception:
self.this = this
__swig_destroy__ = _uncertainty.delete_MauntzKucherenkoSensitivityAlgorithm
__del__ = lambda self: None
MauntzKucherenkoSensitivityAlgorithm_swigregister = _uncertainty.MauntzKucherenkoSensitivityAlgorithm_swigregister
MauntzKucherenkoSensitivityAlgorithm_swigregister(MauntzKucherenkoSensitivityAlgorithm)
import openturns.transformation
import openturns.analytical
import openturns.simulation
import openturns.stattests
import openturns.model_process
# This file is compatible with both classic and new-style classes.
|