Change GMRF 1D default to Continuous1D from default#61
Conversation
nabriis
left a comment
There was a problem hiding this comment.
Hi @jakobsj ,
Some behavior related to default_geometry will disappear for GMRF if we change this.
For example if a PDEModel uses a StepExpansion for the domain, the user does not have to explicitly add that geometry to a prior because domain geometry of a model takes priority over a defaultGeometry. However with this change the user would have to explicitly add the geometry to the GMRF prior.
I think a better solution is to think of a default geometry for 1D and for 2D (even ND i guess).
In this case if we have e.g. a Wavelet2D on a model domain geometry, the 2D default geometry on the GMRF prior could be allowed to be overwritten (matching behavior of the 1D case)
Hope that makes sense.
|
Right I see the point. This was motivated from wanting to make the point that GMRF automatically has a Continuous1D or Continuous2D assigned based on dom. But in 1D it doesn't currently and in 2D gets Image2D in fact. Maybe better to remove the automatic creation of Image2D as the geometry? Alternatively, could we replace our default geometries by Continuous1D (and Continous2D)? |
|
For now maybe easier not to mention GMRF at all in the notebook? |
From my point of view I see the following user interactions with Geometries as they relate to this discussion.
x = GMRF(np.zeros(n), 1, physical_dim=2)
x.sample(5).plot() #User expects to see 2D plots because GMRF is defined with physical_dim=2
# Assume we have a PDEModel with variable name model and domain geometry FEniCSContinuous or StepExpansion etc.
# We sample a simple posterior problem as follows:
x = GMRF(np.zeros(n), 1) # Or Gaussian or Uniform etc.
y = Gaussian(model(x), 1)
J = JointDistribution(y,x)
P = J(y=y_obs)
samples = NUTS(P).sample(200,100)
# User would expect the samples to be visualized as FEniCSContinuous or StepExpansion -type plots.
samples["x"].funvals.plot()
# Assume we have a PDEModel with variable name model and domain geometry FEniCSMesh2D or Continuous2D
# We sample a simple posterior problem as follows:
x = GMRF(np.zeros(n), 1, physical_dim=2) # Or Gaussian (without physical_dim)
y = Gaussian(model(x), 1)
J = JointDistribution(y,x)
P = J(y=y_obs) # Code fails here with error: geometry of x (Image2D) does not match domain geometry of model (Continuous2D)
# The user would expect this to work similar to the above case, namely that if they do not specify a geometry for a distribution, the domain geometry from the model would be used.These cases show they we need a dimension aware (1D, 2D etc.) default geometry, which has a default type visualization, but can be overwritten by geometries that are actually specified and match the dimension. |
@jakobsj, Yes for sure easier not to mention it, but it would be nice to actually have this feature. |
|
In the interest of time I will remove GMRF for now until this has been
resolved.
Could Continous1D and 2D etc replace default geometry to achieve the
desired result? Default geometry pretty much behaves like
Continuous1D anyway?
…On Wed, 7 Sept 2022 at 14:53, Nicolai André Brogaard Riis < ***@***.***> wrote:
For now maybe easier not to mention GMRF at all in the notebook?
@jakobsj <https://github.com/jakobsj>, Yes for sure easier not to mention
it, but it would be nice to actually have this feature.
—
Reply to this email directly, view it on GitHub
<#61 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACMDSCAUJBJHH5E7ASLVMALV5CF35ANCNFSM6AAAAAAQGWSPMY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
We explicitly use DefaultGeometry instead to assign it a "lower priority". We need to know if the user explicitly chose Continous1D for a prior and not the default. |
|
Why? What is achieved by distinguishing Continuous1D from the default?
On Wed, 7 Sept 2022 at 15:04, Nicolai André Brogaard Riis <
***@***.***> wrote:
… In the interest of time I will remove GMRF for now until this has been
resolved. Could Continous1D and 2D etc replace default geometry to achieve
the desired result? Default geometry pretty much behaves like Continuous1D
anyway?
… <#m_-4414588984987191916_>
On Wed, 7 Sept 2022 at 14:53, Nicolai André Brogaard Riis < *@*.*> wrote:
For now maybe easier not to mention GMRF at all in the notebook? @jakobsj
<https://github.com/jakobsj> https://github.com/jakobsj
<https://github.com/jakobsj>, Yes for sure easier not to mention it, but it
would be nice to actually have this feature. — Reply to this email
directly, view it on GitHub <#61 (comment)
<#61 (comment)>>, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/ACMDSCAUJBJHH5E7ASLVMALV5CF35ANCNFSM6AAAAAAQGWSPMY
<https://github.com/notifications/unsubscribe-auth/ACMDSCAUJBJHH5E7ASLVMALV5CF35ANCNFSM6AAAAAAQGWSPMY>
. You are receiving this because you were mentioned.Message ID: @.*>
We explicitly use DefaultGeometry instead to assign it a "lower priority".
We need to know if the user explicitly chose Continous1D for a prior and
not the default.
—
Reply to this email directly, view it on GitHub
<#61 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACMDSCFZUBF643L2JIHXHLLV5CHETANCNFSM6AAAAAAQGWSPMY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
It allows us to detect easily in the code if the user set a geometry or the geometry was set as default (that is user did not choose it). If the user explicitly sets a geometry we will never overwrite it, but if its a default we can overwrite when it makes sense. For example I would expect this to pass: # Assume we have a PDEModel with variable name model and domain geometry FEniCSContinuous or StepExpansion etc.
x = GMRF(np.zeros(n), 1) # Or Gaussian or Uniform etc.
y = Gaussian(model(x), 1)
J = JointDistribution(y,x)
P = J(y=y_obs)
samples = NUTS(P).sample(200,100)
samples["x"].funvals.plot()
# User would expect the samples to be visualized as FEniCSContinuous or StepExpansion -type plots.But this to fail: # Assume we have a PDEModel with variable name model and domain geometry FEniCSContinuous or StepExpansion etc.
x = GMRF(np.zeros(n), 1, geometry=Continuous1D(n)) # Or Gaussian or Uniform etc.
y = Gaussian(model(x), 1)
J = JointDistribution(y,x)
P = J(y=y_obs) # Should fail because model domain geometry does not match x geometry. |
|
OK, let us discuss later how to progress this. It is not clear to me that a
default2D is what we want as that seems to place some assumptions on the
geometry (namely it being 2D). It seems to me that the point of GMRF (based
on the 2D behaviour) is to make an automatic choice of an actual
non-default geometry for the user, which currently is Image2D (but could
also be Continous2D). To be consistent, I would expect the default
behaviour in 1D to also make a non-default choice, such as Continuous1D. In
this way, GMRF is different from more basic distributions such as Gaussian.
But again let us return to this later. I've removed it from nb2, please
could you take a look again - thanks!
…On Wed, 7 Sept 2022 at 15:14, Nicolai André Brogaard Riis < ***@***.***> wrote:
Why? What is achieved by distinguishing Continuous1D from the default?
It allows us to detect easily in the code if the user set a geometry or
the geometry was set as default (that is user did not choose it). If the
user explicitly sets a geometry we will never overwrite it, but if its a
default we can overwrite when it makes sense.
For example I would expect this to pass:
# Assume we have a PDEModel with variable name model and domain geometry FEniCSContinuous or StepExpansion etc.x = GMRF(np.zeros(n), 1) # Or Gaussian or Uniform etc.y = Gaussian(model(x), 1)J = JointDistribution(y,x)P = J(y=y_obs)samples = NUTS(P).sample(200,100)samples["x"].funvals.plot() # User would expect the samples to be visualized as FEniCSContinuous or StepExpansion -type plots.
But this to fail:
# Assume we have a PDEModel with variable name model and domain geometry FEniCSContinuous or StepExpansion etc.x = GMRF(np.zeros(n), 1, geometry=Continuous1D(n)) # Or Gaussian or Uniform etc.y = Gaussian(model(x), 1)J = JointDistribution(y,x)P = J(y=y_obs) # Should fail because model domain geometry does not match x geometry.
—
Reply to this email directly, view it on GitHub
<#61 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACMDSCG22LBRD5G7APTZOATV5CIMRANCNFSM6AAAAAAQGWSPMY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
|
This is a good point. Lets create an issue and find a good way to deal with it.
|
Fix 1D geometry for GMRF to avoid having just the default geometry. Needed for nb2.