# Can i sample without any observation but only potential?

trying to sample from a fabricated discrete distribution but with another fabricated likelihood.

but somehow pymc don’t sample for me e.g.

A ~ N(0, NxN).
B = (C . A > 0) . A
def potential(B):
return scalar_function(B)
pm.MCMC([A, B, potential])
pm.sample(100)

You should be able to sample in many cases without explicitly using an observation. Would you be willing to post a self-contained code section that describes your problem in a bit more detail?

sure, and sorry i was using pymc2. it’s a lot of trouble to do boolean operation with theano

``````import numpy as np
import pymc as pm
gs = np.random.uniform(size=(4, 3))
seed = pm.Normal('seed', 0, 1, size=[gs.shape, 1])
@pm.deterministic(name='label', trace=True)
def label(seed=seed):
return gs.dot(seed) > 0

@pm.potential
def value(label=label):
return label.T.dot(gs).sum()

model = pm.MCMC([seed, label, value])
trace = model.sample(10)
assert trace != None
``````

I’ve written code for what I think you want to do in PyMC3. I apologize that I can’t answer with PyMC2 because I don’t know much about how to use it.

``````import pymc3 as pm
import numpy as np

gs = np.random.uniform(size=(4, 3))

with pm.Model() as model:
seed  = pm.Normal('seed', 0, 1, shape=[gs.shape, 1])
label = pm.Deterministic('label',pm.math.gt(pm.math.dot(gs,seed),0))
value = pm.Potential('value',pm.math.sum(pm.math.dot(label.T,gs)))
step  = pm.Metropolis()
trace = pm.sample(step=step)
``````
2 Likes