Exemplo n.º 1
0
            chain.get_parameter(1),
            c=exp(p - max(p)),
            marker='.')

plt.xlabel('parameter 1')
plt.ylabel('parameter 2')
plt.grid()
plt.show()

# We can see from this plot that in order to take a representative sample,
# some early portion of the chain must be removed. This is referred to as
# the 'burn-in' period. This period allows the chain to both find the high
# density areas, and adjust the proposal widths to their optimal values.

# The plot_diagnostics() method can help us decide what size of burn-in to use:
chain.plot_diagnostics()

# Occasionally samples are also 'thinned' by a factor of n (where only every
# n'th sample is used) in order to reduce the size of the data set for
# storage, or to produce uncorrelated samples.

# based on the diagnostics we can choose to manually set a global burn and
# thin value, which is used (unless otherwise specified) by all methods which
# access the samples
chain.burn = 2000
chain.thin = 5

# the burn-in and thinning can also be set automatically as follows:
chain.autoselect_burn_and_thin()

# After discarding burn-in, what we have left should be a representative
Exemplo n.º 2
0
            chain.get_parameter(1),
            c=exp(p - max(p)),
            marker='.')
plt.xlabel('parameter 1')
plt.ylabel('parameter 2')
plt.grid()
plt.savefig('initial_scatter.png')
plt.close()

# We can see from this plot that in order to take a representative sample,
# some early portion of the chain must be removed. This is referred to as
# the 'burn-in' period. This period allows the chain to both find the high
# density areas, and adjust the proposal widths to their optimal values.

# The plot_diagnostics() method can help us decide what size of burn-in to use:
chain.plot_diagnostics(filename='gibbs_diagnostics.png')

# Occasionally samples are also 'thinned' by a factor of n (where only every
# n'th sample is used) in order to reduce the size of the data set for
# storage, or to produce uncorrelated samples.

# based on the diagnostics we can choose to manually set a global burn and
# thin value, which is used (unless otherwise specified) by all methods which
# access the samples
chain.burn = 10000
chain.thin = 10

# the burn-in and thinning can also be set automatically as follows:
# chain.autoselect_burn_and_thin()

# After discarding burn-in, what we have left should be a representative