-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
480 lines (417 loc) · 22.7 KB
/
index.html
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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="Polynomial Chaos Expansion Demo">
<meta name="author" content="Chi Feng">
<title>Polynomial Chaos Expansion</title>
<!-- Bootstrap core CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.min.js" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]} });
</script>
<script type="text/javascript" async
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<style>
/* Sticky footer styles
-------------------------------------------------- */
html {
position: relative;
min-height: 100%;
}
body {
margin-bottom: 60px; /* Margin bottom by footer height */
}
.footer {
position: absolute;
bottom: 0;
width: 100%;
height: 60px; /* Set the fixed height of the footer here */
line-height: 60px; /* Vertically center the text there */
background-color: #f5f5f5;
}
/* Custom page CSS
-------------------------------------------------- */
/* Not required for template or sticky footer method. */
body { background: #fafafa; }
table { border-collapse: collapse;}
#table, #table th, #table td { border: 10px solid #fafafa;}
#table td { cursor:pointer; }
#table td:hover { background-color: #fffaee; }
table.quadrature, table.quadrature th, table.quadrature td { border: 1px solid #666; }
table td { padding: 5px; background: #fff; }
div.multiindex, div.coeff, div.poly { text-align:center; }
</style>
</head>
<body>
<script src="lib/linalg.js"></script>
<script src="pce.js"></script>
<div id="modal" class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="modal-title"></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body" id="modal-body">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!-- Begin page content -->
<main role="main" class="container">
<h2 class="mt-5">Polynomial Chaos Expansion</h2>
<div class="row">
<div class="col-sm">
<div id="modal"></div>
<div id="main-formula">A <strong>polynomial chaos expansion</strong> is a series expansion of a random variable $X=f(\boldsymbol \xi)$ in the following form: $$\color{blue}{f(\boldsymbol{\xi})}\approx \color{red}{\sum_{\mathbf{j}\in\mathcal{J}}\gamma_{\mathbf{j}} \psi_{\mathbf{j}}(\xi_1,\xi_2,\dots,\xi_n)}.$$
In this expansion, $\mathbf{j}=(j_1,\dots,j_n)^T\in\mathbb{N}^n$ is a <strong>multiindex</strong> and $\gamma_{\mathbf{j}}$ are scalar coefficients. $\{\xi_i\}_{i=1}^n$ are independent random variables defined on the probability space $(\Omega,\mathcal{F}(\boldsymbol{\xi}),\mathbb{P})$ and $\boldsymbol{\xi}=(\xi_1,\dots,\xi_n)^T$. $\psi_{\mathbf{j}}(\xi_1,\dots,\xi_n)$ is a $n$-variate orthogonal polynomial with the highest degree term being $\xi_1^{j_1}\xi_2^{j_2}\cdots\xi_n^{j_n}$. The polynomials $\{\psi_\mathbf{j}\}_{\mathbf{j}>\mathbf{0}}$ are orthogonal, i.e.,
$$\langle \psi_\boldsymbol{\alpha},\psi_\boldsymbol{\beta}\rangle:=\mathbb{E}[\psi_\boldsymbol{\alpha}\psi_\boldsymbol{\beta}]=\int \psi_\boldsymbol{\alpha}(\boldsymbol\xi)\psi_\boldsymbol{\beta}(\boldsymbol\xi)p_1(\xi_1)\cdots p_n(\xi_n)\,\text{d}\boldsymbol{\xi}=\delta_{\boldsymbol{\alpha}\boldsymbol{\beta}}$$
where $p_i(\xi_i)$ is the pdf of $\xi_i$.
</div>
</div>
<div class="col-sm">
<div id="inputs">
<form id="form">
<div class="form-group">
<label class="form-label">$X=f(\boldsymbol{\xi})$: random variable we want to approximate</label>
<textarea class="form-control" name="function">2*Math.exp(0.2*Math.sin(x[0]))+2*x[0]*x[1]-2*x[1]*x[1]</textarea>
<small class="form-text text-muted">Function must be a javascript expression in terms of <code>x[0]</code> and <code>x[1]</code>.</small>
</div>
<div class="row">
<div class="col-sm">
<div class="form-group">
<label class="form-label">$\xi_1$ distribution</label>
<select class="form-control" name="germ1">
<option value="NORMAL">Normal(0, 1)</option>
<option value="UNIFORM">Uniform(-1, 1)</option>
</select>
</div>
</div>
<div class="col-sm">
<div class="form-group">
<label class="form-label">$\xi_2$ distribution</label>
<select class="form-control" name="germ2" >
<option value="NORMAL">Normal(0, 1)</option>
<option value="UNIFORM" selected>Uniform(-1, 1)</option>
</select>
</div>
</div>
</div>
<div class="form-group">
<label class="form-label">Maximum polynomial orders</label>
<div class="row">
<div class="col-sm">
<input type="text" class="form-control" name="polyOrder1" value="3" >
</div>
<div class="col-sm">
<input type="text" class="form-control" name="polyOrder2" value="3" >
</div>
</div>
</div>
<div class="form-group">
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="plotdim" id="inlineRadio1" value="2">
<label class="form-check-label" for="inlineRadio1">2D plots</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="plotdim" id="inlineRadio2" value="3" checked>
<label class="form-check-label" for="inlineRadio2">3D plots (requires webGL)</label>
</div>
</div>
<div class="form-group">
<input type="submit" class="btn btn-primary" value="Compute PCE">
<span class="small" id="running_indicator"></span>
</div>
</form>
</div>
</div>
</div>
<br />
<div class="row" id="results" style="display:none">
<div class="col-sm">
<h3>Results</h3>
<div id="germs"></div>
<div id="multiindex"></div>
<div id="moments">
<div id="mean"></div>
<div id="variance"></div>
</div>
</div>
</div>
<div>
<div class="row">
<div class="col-sm text-center">
<!-- <p>Surface plot</p> -->
<div id="surface" style="display:inline-block"></div>
</div>
<div class="col-sm text-center">
<!-- <p>Contour plot</p> -->
<div id="contour" style="display:inline-block"></div>
</div>
</div>
</div>
<table id="table"></table>
<script>
window.addEventListener("load", function() {
// Create canvas element. The canvas is not added to the
// document itself, so it is never displayed in the
// browser window.
var canvas = document.createElement("canvas");
// Get WebGLRenderingContext from canvas element.
var gl = canvas.getContext("webgl")
|| canvas.getContext("experimental-webgl");
// Report the result.
if (gl && gl instanceof WebGLRenderingContext) {
console.log("Congratulations! Your browser supports WebGL.");
} else {
console.log("Failed to get WebGL context. Your browser or device may not support WebGL.");
$("#inlineRadio1").prop("checked", true);
$("#inlineRadio2").prop("disabled", true);
}
}, false);
$("#form").submit(function(event) {
event.preventDefault();
$(".modal:visible").find(".close").trigger('click');
$('#form').find('input[type="submit"]').attr('value','Running...');
$('#form').find('input[type="submit"]').attr('disabled','true');
setTimeout(function(){ run(); }, 500);
});
function nicePrecision(x) {
if (Math.abs(x) < 1e-11) return '0';
if (Math.abs(x - Math.round(x)) < 1e-11) return Math.round(x);
return x.toFixed(3);
}
// get symmetric limits of a function so that the colormaps are centered at zero
function getSymmetricLimits(z, n) {
const min = (a, b) => Math.min(a, b);
const max = (a, b) => Math.max(a, b);
var zmin = z.map(row=>row.reduce(min)).reduce(min);
var zmax = z.map(row=>row.reduce(max)).reduce(max);
var zlim = [-Math.max(Math.abs(zmin), Math.abs(zmax)), Math.max(Math.abs(zmin), Math.abs(zmax))];
var zstep = (zlim[1] - zlim[0]) / n;
return {min: zlim[0], max: zlim[1], step: zstep};
}
function getTensorPolyLatex(germs, multiindex) {
return germs.map(function (type, i) {
switch (type) {
case germType.NORMAL: return 'H_{' + multiindex[i] + '}(\\xi_{' + (i+1) + '})';
case germType.UNIFORM: return 'P_{' + multiindex[i] + '}(\\xi_{' + (i+1) + '})';
}
}).join('');
}
function getGermsLatex(germs) {
return germs.map(function (type, i) {
switch (type) {
case germType.NORMAL: return '\\xi_{' + (i+1) + '}\\sim\\mathcal{N}(0,1)';
case germType.UNIFORM: return '\\xi_{' + (i+1) + '}\\sim\\mathcal{U}(-1,1)';
}
}).join(';\\\\');
}
function getOrdersLatex(orders) {
return orders.map((order, i) => '0\\leq j_{' + (i+1) + '}\\leq ' + order).join('\\text{ and }');
}
function getQuad1DLatex(p, multiindex, k) {
var latex = [];
var p0 = p.quadOrder(multiindex[0]);
var p1 = p.quadOrder(multiindex[1]);
var abscissae, weights;
var quad;
switch (p.germs[0]) {
case germType.NORMAL: quad = GaussianQuadrature.hermite; break;
case germType.UNIFORM: quad = GaussianQuadrature.legendre; break;
}
var abscissae = quad[p0].abscissae.map(nicePrecision);
var weights = quad[p0].weights.map(nicePrecision);
var row0 = '<tr><td></td>';
var row1 = '<tr><td>$x^{(i)}$</td>';
var row2 = '<tr><td>$w^{(i)}$</td>';
for (var i = 0; i < abscissae.length; i++) {
row0 += '<td>$i=' + (i+1) + '$</td>';
row1 += '<td>' + abscissae[i] + '</td>';
row2 += '<td>' + weights[i] + '</td>';
}
var table0 = '<table class="quadrature">' + row0 + '</tr>' + row1 + '</tr>' + row2 + '</tr></table>';
switch (p.germs[1]) {
case germType.NORMAL: quad = GaussianQuadrature.hermite; break;
case germType.UNIFORM: quad = GaussianQuadrature.legendre; break;
}
abscissae = quad[p1].abscissae.map(nicePrecision);
weights = quad[p1].weights.map(nicePrecision);
row0 = '<tr><td></td>';
row1 = '<tr><td>$x^{(i)}$</td>';
row2 = '<tr><td>$w^{(i)}$</td>';
for (i = 0; i < abscissae.length; i++) {
row0 += '<td>$i=' + (i+1) + '$</td>';
row1 += '<td>' + abscissae[i] + '</td>';
row2 += '<td>' + weights[i] + '</td>';
}
var table1 = '<table class="quadrature">' + row0 + '</tr>' + row1 + '</tr>' + row2 + '</tr></table>';
var prod = '$$Q_{' + multiindex[0] + ',' + multiindex[1] + '}^{(1,2)}[h]=(Q_{' + multiindex[0] + '}^{(1)}\\otimes Q_{' + multiindex[1] + '}^{(2)})[h]=\\sum_{i_1=1}^{'+ (p0+1) +'}\\sum_{i_2=1}^{'+ (p1+1) +'} h(x_1^{(i_1)},x_2^{(i_2)}) w^{(i_1)}w^{(i_2)}$$';
var table2 = '<table class="quadrature">';
table2 += '<tr><td>$(i_1,i_2)$</td><td>$(x_1^{(i_1)},x_2^{(i_2)})$</td><td>$w^{(i_1)}w^{(i_2)}$</td></tr>';
var indices = cartprod.apply(null, [range(quad[p0].abscissae.length), range(quad[p1].abscissae.length)]);
console.log(indices);
for (i=1; i < p.tensorQuads[k].abscissae.length; i++) {
table2 += '<tr><td>(' + (indices[i][0]+1) + ', ' + (indices[i][1]+1) + ')</td>';
table2 += '<td>(' + p.tensorQuads[k].abscissae[i].map(nicePrecision).join(', ') + ')</td>';
table2 += '<td>' + nicePrecision(p.tensorQuads[k].weights[i].reduce(product)) + '</td></tr>';
}
table2 += '</table>'
return '<p>1D quadrature rule for first dimension with polynomial order $j_1=' + multiindex[0] + '$ $$\\int f(x)\\,\\rho(x)\\,\\text{d}x\\approx Q_{' + multiindex[0] + '}^{(1)}[h]=\\sum_{i=1}^{q(' + multiindex[0] + ')=' + (p0+1) +'}h(x^{(i)})\\,w^{(i)}$$ ' + table0 + '</p><p>1D quadrature rule for second dimension with polynomial order $j_2=' + multiindex[1] + '$' +
'$$\\int f(x)\\,\\rho(x)\\,\\text{d}x\\approx Q_{' + multiindex[1] + '}^{(2)}[h]=\\sum_{i=1}^{q(' + multiindex[1] + ')=' + (p1+1) +'}h(x^{(i)})\\,w^{(i)}$$ ' + table1 + '</p><p>2D quadrature rule: </p> ' + prod + table2 + '</p><p>Finally, $$ \\gamma_{('+multiindex[0] + ',' + multiindex[1]+')} = \\frac{Q_{' + multiindex[0] + ',' + multiindex[1] + '}^{(1,2)}[f\\psi_{('+ multiindex[0] + ',' + multiindex[1]+')}]}{\\langle\\psi_{('+ multiindex[0] + ',' + multiindex[1]+')}^2\\rangle}=' + nicePrecision(p.coeffs[k]) + '$$';
}
function getQuadTensorLatex(germs, multiindex) {
}
function hide_modal() {
$(".modal:visible").find(".close").trigger('click');
}
function run() {
var fstring = $('#form').find('textarea[name="function"]').val();
console.log('function: ' + fstring);
var f = function(x) {
// var a = 1, b = 100;
// return Math.pow(a-x[0],2) + b * Math.pow(x[1]-x[0]*x[0], 2);
// return 2*Math.exp(0.2*Math.sin(x[0]))+2*x[0]*x[1]-2*x[1]*x[1];
return eval(fstring);
};
var germs = [germType.NORMAL, germType.NORMAL];
if ($('#form').find('select[name="germ1"]').val() == 'UNIFORM')
germs[0] = germType.UNIFORM;
if ($('#form').find('select[name="germ2"]').val() == 'UNIFORM')
germs[1] = germType.UNIFORM;
var plotdim = parseInt($('input[name=plotdim]:checked').val());
var polyOrders = [
parseInt($('#form').find('input[name="polyOrder1"]').val()),
parseInt($('#form').find('input[name="polyOrder2"]').val())
];
var totalOrder = polyOrders.reduce((a, b) => Math.max(a,b));
var p = new PCExpansion(f, germs, polyOrders, totalOrder);
var moments = p.getMoments();
document.getElementById('multiindex').innerHTML = '$$\\begin{align}\\mathcal{J}&=\\{\\mathbf{j}:\\|\\mathbf{j}\\|_1\\leq' + p.totalOrder + ',\\text{ and }' + getOrdersLatex(p.orders) + '\\}\\\\&=\\{' + p.multiindexSet.map(multiindex=>'(' + multiindex.join(',') + ')').join(',') + '\\}\\end{align}$$';
document.getElementById('mean').innerHTML = '$$\\mathbb{E}[f(\\boldsymbol{\\xi})] \\approx \\gamma_{(0,0)} = ' + nicePrecision(moments.mean) + '$$';
document.getElementById('variance').innerHTML = '$$\\text{Var}[f(\\boldsymbol{\\xi})] \\approx \\sum_{\\mathbf{j}\\in\\mathcal{J}}\\gamma_{\\mathbf{j}}^2\\langle\\psi_{\\mathbf{j}}^2\\rangle = ' + nicePrecision(moments.variance) + '$$';
document.getElementById('germs').innerHTML = '$$' + getGermsLatex(germs) + '$$';
// create table of expansion terms
document.getElementById('table').innerHTML = '';
var row = document.createElement('tr');
p.multiindexSet.forEach(function (multiindex, k) {
// every time outer index changes, create a new table row
if (k > 0 && multiindex[0] != p.multiindexSet[k-1][0]) {
table.appendChild(row);
row = document.createElement('tr');
}
var cell = document.createElement('td');
cell.setAttribute("id", 'cell-' + multiindex[0] + '-' + multiindex[1]);
var coeff = '$\\gamma_{(' + multiindex[0] + ',' + multiindex[1] + ')}=' + nicePrecision(p.coeffs[k]) + '$';
var poly = '$\\psi_{(' + multiindex[0] + ',' + multiindex[1] + ')}(\\boldsymbol{\\xi})=' + getTensorPolyLatex(germs, multiindex) +'$';
html = [
//'<div class="multiindex">$\\mathbf{j}=(' + multiindex[0] + ',' + multiindex[1] + ')$</div>',
'<div class="coeff">' + coeff + '</div>',
'<div class="poly">' + poly + '</div>',
'<div class="contourplot" id="contour-' + multiindex[0] + '-' + multiindex[1] + '"></div>'
];
cell.innerHTML = html.join('');
cell.onclick = function() {
var quad1d1 = getQuad1DLatex(p, multiindex, k);
$('#modal-title').html('How to find $\\gamma_{(' + multiindex[0] + ',' + multiindex[1] + ')}$');
$('#modal-body').html(quad1d1);
$('#modal').modal();
MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
};
row.appendChild(cell);
});
table.appendChild(row);
document.body.appendChild(table);
var npts = 51;
var xmin = germs[0] == germType.NORMAL ? -3 : -1, xmax = germs[0] == germType.NORMAL ? 3 : 1;
var ymin = germs[1] == germType.NORMAL ? -3 : -1, ymax = germs[1] == germType.NORMAL ? 3 : 1;
var x = Array2d.linspace(xmin,xmax,npts).data;
var y = Array2d.linspace(ymin,ymax,npts).data;
var z = Array2d.build((i,j) => p.evaluate([x[i], y[j]]), x.length, y.length).toArray();
var zlim = getSymmetricLimits(z, 20);
var ztrue = Array2d.build((i,j) => p.f([x[i], y[j]]), x.length, y.length).toArray()
.map(row => row.map(val => Math.max(Math.min(val, zlim.max), zlim.min))); // clamp to zlimits
var data = [{
x: x, y: y, z: z,
type: 'contour',
colorscale:[['0.0', '#f00'],['1.0', '#f00']],
autocontour: false,
contours: { start: zlim.min, end: zlim.max, size: zlim.step, coloring: 'lines' },
hoverinfo:'none',showscale:false,
}, {
x: x, y: y, z: ztrue,
type: 'contour' ,
colorscale:[['0.0', '#00f'],['1.0', '#00f']],
autocontour: false,
contours: { start: zlim.min, end: zlim.max, size: zlim.step, coloring: 'lines' },
hoverinfo:'none',showscale:false,
}];
var layout = { autosize: true, width: 500, height: 400, margin: { l: 40, r: 40, b: 50, t: 10, pad: 0 }};
if (plotdim == 2) {
Plotly.newPlot('contour', data, layout, {displayModeBar: false});
}
if (plotdim == 3){
Plotly.newPlot('contour', data, layout, {displayModeBar: false});
var data = [
{x:x,y:y,z:z,type:'surface', opacity:1,showscale:false,hoverinfo:'none',colorscale: [['0.0', '#f00'],['1.0', '#f00']],cmin:zlim.min, cmax:zlim.max},
{x:x,y:y,z:ztrue,type:'surface', opacity:0.5, colorscale: [['0.0', '#00f'],['1.0', '#00f']],showscale:false,hoverinfo:'none',cmin:zlim.min, cmax:zlim.max}
];
Plotly.newPlot('surface', data, layout, {displayModeBar: false});
}
p.multiindexSet.forEach(function (multiindex, k) {
console.log(k);
var z = Array2d.build((i, j) => p.evalTensorPoly(multiindex, [x[i], y[j]]), x.length, y.length).toArray();
var zlim = getSymmetricLimits(z, 10);
var n = p.tensorQuads[k].abscissae.length;
var abscissae = Array2d.build((i, j) => p.tensorQuads[k].abscissae[j][i], 2, n).toArray();
var weights = Array2d.build((i, j) => Math.sqrt(p.tensorQuads[k].weights[j].reduce(product)) * 20, 1, n).data;
// var zcoord = Array2d.build((i, j) => p.f(p.tensorQuads[k].abscissae[j]) * p.evalTensorPoly(multiindex, p.tensorQuads[k].abscissae[j]), 1, n).data;
var zcoord = Array2d.build((i, j) => zlim.min, 1, n).data;
if (plotdim == 3) {
var data = [
{ x: abscissae[0], y: abscissae[1], z: zcoord, type: 'scatter3d', mode: 'markers',
marker: { size: weights, color: '#000', line: { color: '#000' } }, opacity:0.9, hoverinfo:'none'},
{ x:x, y:y, z:z, type:'surface', opacity:0.9, showscale:false, cmin:zlim.min, cmax:zlim.max, hoverinfo:'none' },
]
var layout = { autosize: false, width: 300, height: 200, margin: { l: 10, r: 10, b: 10, t: 10, pad: 0 } }
Plotly.newPlot('contour-' + multiindex[0] + '-' + multiindex[1], data, layout, {displayModeBar: false});
} else if (plotdim == 2) {
var data = [
{ x: abscissae[0], y: abscissae[1], type: 'scatter', mode: 'markers',
marker: { size: weights, color: '#000', line: { color: '#000' } }, opacity:0.9, hoverinfo:'none'},
{ x:x, y:y, z:z, type:'contour', cmin:zlim.min, cmax:zlim.max, hoverinfo:'none' },
]
var layout = { autosize: false, width: 300, height: 200, margin: { l: 10, r: 10, b: 10, t: 10, pad: 0 } }
Plotly.newPlot('contour-' + multiindex[0] + '-' + multiindex[1], data, layout, {displayModeBar: false});
}
if (Math.abs(p.coeffs[k]) < 1e-11) {
document.getElementById('contour-' + multiindex[0] + '-' + multiindex[1]).style.opacity = 0.25;
}
});
// $('#running_indicator').html('');
$('#form').find('input[type="submit"]').attr('value', 'Compute PCE');
$('#form').find('input[type="submit"]').removeAttr('disabled');
$('#results').show();
MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
};
</script>
</main>
<footer class="footer">
<div class="container">
<span class="text-muted">Github <a href="https://github.com/chi-feng/pce-demo">https://github.com/chi-feng/pce-demo</a></span>
</div>
</footer>
</body>
</html>