-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathuncertain_prop.py
More file actions
48 lines (30 loc) · 1.13 KB
/
uncertain_prop.py
File metadata and controls
48 lines (30 loc) · 1.13 KB
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
import arraycontext
from dataclasses import dataclass
import numpy as np # for the data types
from pytools.tag import Tag
from arraycontext.impl.pytato.__init__ import (PytatoPyOpenCLArrayContextUQ,
PytatoPyOpenCLArrayContext)
# The goal of this file is to propagate the uncertainty in an array to the output.
my_context = arraycontext.impl.pytato.PytatoPyOpenCLArrayContext
a = my_context.zeros(my_context, shape=(5,5), dtype=np.int32) + 2
b = my_context.zeros(my_context, (5,5), np.int32) + 15
print(a)
print("========================================================")
print(b)
print("========================================================")
# Eq: z = x + y
# Assumptions: x and y are independently uncertain.
x = np.random.random((15,5))
x1 = np.random.random((15,5))
x2 = np.random.random((15,5))
y = np.random.random((15,5))
y1 = np.random.random((15,5))
y2 = np.random.random((15,5))
actx = PytatoPyOpenCLArrayContextUQ
out = actx.pack_for_uq(actx,"x", x, x1, x2, "y", y, y1, y2)
print("===============OUT======================")
print(out)
x = out["x"]
y = out["y"]
breakpoint()
x + y