[1]:
import pyobs
import numpy
import matplotlib.pyplot as plt
%matplotlib notebook
[2]:
mu = 0.5 # central values
cov = (mu*0.5)**2 # error^2
# autocorrelation time
tau=4.0
rng = pyobs.random.generator('tutorial-v2')
data1 = rng.markov_chain(mu,cov,tau,1000)
data2 = rng.markov_chain(mu,cov,tau,600)
Random generator initialized with seed = 2458954236 [tutorial-v2]
[3]:
obsA = pyobs.observable(description='Observable A')
obsA.create('EnsA',[data1,data2],rname=['replica1','replica2'])
obsA.peek()
Observable with shape = (1,)
- description: Observable A
- created by mbruno at macthxbruno.fritz.box on Sat Aug 20 14:42:09 2022
- size: 73 KB
- mean: [0.57392611]
- Ensemble EnsA
- Replica replica1 with ncnfg 1000
- Replica replica2 with ncnfg 600
temporary additional memory required 0.015 MB
Now we artificially create a stream with holes. To make sure that the autocorrelations are still treated properly we must provide the configuration index
[4]:
mask = rng.sample_boolean(1000)
icnfg = numpy.arange(1000)
obsB = pyobs.observable(description='MC history w/o holes')
obsB.create('EnsA',data1, icnfg=list(icnfg))
obsB.peek()
obsC = pyobs.observable(description='MC history w/ holes')
obsC.create('EnsA',data1[mask], icnfg=list(icnfg[mask]))
obsC.peek()
Observable with shape = (1,)
- description: MC history w/o holes
- created by mbruno at macthxbruno.fritz.box on Sat Aug 20 14:42:09 2022
- size: 46 KB
- mean: [0.77002284]
- Ensemble EnsA
- Replica 0 with ncnfg 1000
temporary additional memory required 0.015 MB
Observable with shape = (1,)
- description: MC history w/ holes
- created by mbruno at macthxbruno.fritz.box on Sat Aug 20 14:42:09 2022
- size: 32 KB
- mean: [0.6241264]
- Ensemble EnsA
- Replica 0 with ncnfg 515
temporary additional memory required 0.015 MB
[5]:
print('Full MC history')
print(obsB.tauint())
print('MC history w/ holes')
print(obsC.tauint())
Full MC history
{'EnsA': [array([3.82836706]), array([1.05540797])]}
MC history w/ holes
{'EnsA': [array([3.91062104]), array([1.37858042])]}
[ ]: