Note
Go to the end to download the full example code.
Expectation of global descriptors in 1D#
This example shows how to compute theoretical expectations of total length (L1) and Euler characteristic (L0) of excursion sets as a function of the excursion’s threshold. Excrusions are define here as the subdomain of the domain where the Random Field is defined where the Random Field values are above a certain threshold.
Here the two measures are seen as function of the threshold value.
Monte Carlo results are confronted to the theory.
import spam.excursions
import spam.measurements
import matplotlib.pyplot as plt
import numpy
Correlated Random Field parameters#
First we set all the correlated Random Fields parameters. It is assumed that the distribution is Gaussian with zero mean and the covariance function is Gaussian too.
# set the variance
variance = 1.0
# standard deviation
std = numpy.sqrt(variance)
# correlation length
correlationLength = 10
# length of the domain
length = 100.0
# set the thresholds between -5 and 5
thresholds = numpy.linspace(-5, 5, 50)
Compute the two theoretical expected measures#
The two measures of the excursion (total length (1) and Euler characteristic (0)) are computed and ploted for every thresholds
# spatial dimension
spatialDimension = 1
# the measure number 1
totalLength = spam.excursions.expectedMesures(thresholds, 1, spatialDimension, std=std, lc=correlationLength, a=length)
# the measure number 0
eulerCharac = spam.excursions.expectedMesures(thresholds, 0, spatialDimension, std=std, lc=correlationLength, a=length)
# plt.figure()
# plt.xlabel("Threshold")
# plt.title("Total length")
# plt.plot(thresholds, totalLength, 'r')
#
# plt.figure()
# plt.xlabel("Threshold")
# plt.title("Euler characteristic")
# plt.plot(thresholds, eulerCharac, 'r')
Generate 1000 realisations of the correlated Random Field#
In order to compare the theoretical values to Monte Carlo results, first 1000 realisations of a correlated Random Field are generated.
# number of realisations
nRea = 500
nNodes = 100
# define the covariance
covarianceParameters = {'len_scale': correlationLength, 'var': variance}
# generate realisations
realisations = spam.excursions.simulateRandomField(lengths=length, nNodes=nNodes, covarianceParameters=covarianceParameters, dim=spatialDimension, nRea=nRea)
plt.figure()
plt.xlabel("Length")
plt.title("First 4 realisations")
for i in range(4):
plt.plot(numpy.linspace(0, length, nNodes), realisations[i])
Generating Field_0000... 0.00 seconds
Generating Field_0001... 0.00 seconds
Generating Field_0002... 0.00 seconds
Generating Field_0003... 0.00 seconds
Generating Field_0004... 0.00 seconds
Generating Field_0005... 0.00 seconds
Generating Field_0006... 0.00 seconds
Generating Field_0007... 0.00 seconds
Generating Field_0008... 0.00 seconds
Generating Field_0009... 0.00 seconds
Generating Field_0010... 0.00 seconds
Generating Field_0011... 0.00 seconds
Generating Field_0012... 0.00 seconds
Generating Field_0013... 0.00 seconds
Generating Field_0014... 0.00 seconds
Generating Field_0015... 0.00 seconds
Generating Field_0016... 0.00 seconds
Generating Field_0017... 0.00 seconds
Generating Field_0018... 0.00 seconds
Generating Field_0019... 0.00 seconds
Generating Field_0020... 0.00 seconds
Generating Field_0021... 0.00 seconds
Generating Field_0022... 0.00 seconds
Generating Field_0023... 0.00 seconds
Generating Field_0024... 0.00 seconds
Generating Field_0025... 0.00 seconds
Generating Field_0026... 0.00 seconds
Generating Field_0027... 0.00 seconds
Generating Field_0028... 0.00 seconds
Generating Field_0029... 0.00 seconds
Generating Field_0030... 0.00 seconds
Generating Field_0031... 0.00 seconds
Generating Field_0032... 0.00 seconds
Generating Field_0033... 0.00 seconds
Generating Field_0034... 0.00 seconds
Generating Field_0035... 0.00 seconds
Generating Field_0036... 0.00 seconds
Generating Field_0037... 0.00 seconds
Generating Field_0038... 0.00 seconds
Generating Field_0039... 0.00 seconds
Generating Field_0040... 0.00 seconds
Generating Field_0041... 0.00 seconds
Generating Field_0042... 0.00 seconds
Generating Field_0043... 0.00 seconds
Generating Field_0044... 0.00 seconds
Generating Field_0045... 0.00 seconds
Generating Field_0046... 0.00 seconds
Generating Field_0047... 0.00 seconds
Generating Field_0048... 0.00 seconds
Generating Field_0049... 0.00 seconds
Generating Field_0050... 0.00 seconds
Generating Field_0051... 0.00 seconds
Generating Field_0052... 0.00 seconds
Generating Field_0053... 0.00 seconds
Generating Field_0054... 0.00 seconds
Generating Field_0055... 0.00 seconds
Generating Field_0056... 0.00 seconds
Generating Field_0057... 0.00 seconds
Generating Field_0058... 0.00 seconds
Generating Field_0059... 0.00 seconds
Generating Field_0060... 0.00 seconds
Generating Field_0061... 0.00 seconds
Generating Field_0062... 0.00 seconds
Generating Field_0063... 0.00 seconds
Generating Field_0064... 0.00 seconds
Generating Field_0065... 0.00 seconds
Generating Field_0066... 0.00 seconds
Generating Field_0067... 0.00 seconds
Generating Field_0068... 0.00 seconds
Generating Field_0069... 0.00 seconds
Generating Field_0070... 0.00 seconds
Generating Field_0071... 0.00 seconds
Generating Field_0072... 0.00 seconds
Generating Field_0073... 0.00 seconds
Generating Field_0074... 0.00 seconds
Generating Field_0075... 0.00 seconds
Generating Field_0076... 0.00 seconds
Generating Field_0077... 0.00 seconds
Generating Field_0078... 0.00 seconds
Generating Field_0079... 0.00 seconds
Generating Field_0080... 0.00 seconds
Generating Field_0081... 0.00 seconds
Generating Field_0082... 0.00 seconds
Generating Field_0083... 0.00 seconds
Generating Field_0084... 0.00 seconds
Generating Field_0085... 0.00 seconds
Generating Field_0086... 0.00 seconds
Generating Field_0087... 0.00 seconds
Generating Field_0088... 0.00 seconds
Generating Field_0089... 0.00 seconds
Generating Field_0090... 0.00 seconds
Generating Field_0091... 0.00 seconds
Generating Field_0092... 0.00 seconds
Generating Field_0093... 0.00 seconds
Generating Field_0094... 0.00 seconds
Generating Field_0095... 0.00 seconds
Generating Field_0096... 0.00 seconds
Generating Field_0097... 0.00 seconds
Generating Field_0098... 0.00 seconds
Generating Field_0099... 0.00 seconds
Generating Field_0100... 0.00 seconds
Generating Field_0101... 0.00 seconds
Generating Field_0102... 0.00 seconds
Generating Field_0103... 0.00 seconds
Generating Field_0104... 0.00 seconds
Generating Field_0105... 0.00 seconds
Generating Field_0106... 0.00 seconds
Generating Field_0107... 0.00 seconds
Generating Field_0108... 0.00 seconds
Generating Field_0109... 0.00 seconds
Generating Field_0110... 0.00 seconds
Generating Field_0111... 0.00 seconds
Generating Field_0112... 0.00 seconds
Generating Field_0113... 0.00 seconds
Generating Field_0114... 0.00 seconds
Generating Field_0115... 0.00 seconds
Generating Field_0116... 0.00 seconds
Generating Field_0117... 0.00 seconds
Generating Field_0118... 0.00 seconds
Generating Field_0119... 0.00 seconds
Generating Field_0120... 0.00 seconds
Generating Field_0121... 0.00 seconds
Generating Field_0122... 0.00 seconds
Generating Field_0123... 0.00 seconds
Generating Field_0124... 0.00 seconds
Generating Field_0125... 0.00 seconds
Generating Field_0126... 0.00 seconds
Generating Field_0127... 0.00 seconds
Generating Field_0128... 0.00 seconds
Generating Field_0129... 0.00 seconds
Generating Field_0130... 0.00 seconds
Generating Field_0131... 0.00 seconds
Generating Field_0132... 0.00 seconds
Generating Field_0133... 0.00 seconds
Generating Field_0134... 0.00 seconds
Generating Field_0135... 0.00 seconds
Generating Field_0136... 0.00 seconds
Generating Field_0137... 0.00 seconds
Generating Field_0138... 0.00 seconds
Generating Field_0139... 0.00 seconds
Generating Field_0140... 0.00 seconds
Generating Field_0141... 0.00 seconds
Generating Field_0142... 0.00 seconds
Generating Field_0143... 0.00 seconds
Generating Field_0144... 0.00 seconds
Generating Field_0145... 0.00 seconds
Generating Field_0146... 0.00 seconds
Generating Field_0147... 0.00 seconds
Generating Field_0148... 0.00 seconds
Generating Field_0149... 0.00 seconds
Generating Field_0150... 0.00 seconds
Generating Field_0151... 0.00 seconds
Generating Field_0152... 0.00 seconds
Generating Field_0153... 0.00 seconds
Generating Field_0154... 0.00 seconds
Generating Field_0155... 0.00 seconds
Generating Field_0156... 0.00 seconds
Generating Field_0157... 0.00 seconds
Generating Field_0158... 0.00 seconds
Generating Field_0159... 0.00 seconds
Generating Field_0160... 0.00 seconds
Generating Field_0161... 0.00 seconds
Generating Field_0162... 0.00 seconds
Generating Field_0163... 0.00 seconds
Generating Field_0164... 0.00 seconds
Generating Field_0165... 0.00 seconds
Generating Field_0166... 0.00 seconds
Generating Field_0167... 0.00 seconds
Generating Field_0168... 0.00 seconds
Generating Field_0169... 0.00 seconds
Generating Field_0170... 0.00 seconds
Generating Field_0171... 0.00 seconds
Generating Field_0172... 0.00 seconds
Generating Field_0173... 0.00 seconds
Generating Field_0174... 0.00 seconds
Generating Field_0175... 0.00 seconds
Generating Field_0176... 0.00 seconds
Generating Field_0177... 0.00 seconds
Generating Field_0178... 0.00 seconds
Generating Field_0179... 0.00 seconds
Generating Field_0180... 0.00 seconds
Generating Field_0181... 0.00 seconds
Generating Field_0182... 0.00 seconds
Generating Field_0183... 0.00 seconds
Generating Field_0184... 0.01 seconds
Generating Field_0185... 0.00 seconds
Generating Field_0186... 0.00 seconds
Generating Field_0187... 0.00 seconds
Generating Field_0188... 0.00 seconds
Generating Field_0189... 0.00 seconds
Generating Field_0190... 0.00 seconds
Generating Field_0191... 0.00 seconds
Generating Field_0192... 0.00 seconds
Generating Field_0193... 0.00 seconds
Generating Field_0194... 0.00 seconds
Generating Field_0195... 0.00 seconds
Generating Field_0196... 0.00 seconds
Generating Field_0197... 0.00 seconds
Generating Field_0198... 0.00 seconds
Generating Field_0199... 0.00 seconds
Generating Field_0200... 0.00 seconds
Generating Field_0201... 0.00 seconds
Generating Field_0202... 0.00 seconds
Generating Field_0203... 0.00 seconds
Generating Field_0204... 0.00 seconds
Generating Field_0205... 0.00 seconds
Generating Field_0206... 0.00 seconds
Generating Field_0207... 0.00 seconds
Generating Field_0208... 0.00 seconds
Generating Field_0209... 0.00 seconds
Generating Field_0210... 0.00 seconds
Generating Field_0211... 0.00 seconds
Generating Field_0212... 0.00 seconds
Generating Field_0213... 0.00 seconds
Generating Field_0214... 0.00 seconds
Generating Field_0215... 0.00 seconds
Generating Field_0216... 0.00 seconds
Generating Field_0217... 0.00 seconds
Generating Field_0218... 0.00 seconds
Generating Field_0219... 0.00 seconds
Generating Field_0220... 0.00 seconds
Generating Field_0221... 0.00 seconds
Generating Field_0222... 0.00 seconds
Generating Field_0223... 0.00 seconds
Generating Field_0224... 0.00 seconds
Generating Field_0225... 0.00 seconds
Generating Field_0226... 0.00 seconds
Generating Field_0227... 0.00 seconds
Generating Field_0228... 0.00 seconds
Generating Field_0229... 0.00 seconds
Generating Field_0230... 0.00 seconds
Generating Field_0231... 0.00 seconds
Generating Field_0232... 0.00 seconds
Generating Field_0233... 0.00 seconds
Generating Field_0234... 0.00 seconds
Generating Field_0235... 0.00 seconds
Generating Field_0236... 0.00 seconds
Generating Field_0237... 0.00 seconds
Generating Field_0238... 0.00 seconds
Generating Field_0239... 0.00 seconds
Generating Field_0240... 0.00 seconds
Generating Field_0241... 0.00 seconds
Generating Field_0242... 0.00 seconds
Generating Field_0243... 0.00 seconds
Generating Field_0244... 0.00 seconds
Generating Field_0245... 0.00 seconds
Generating Field_0246... 0.00 seconds
Generating Field_0247... 0.00 seconds
Generating Field_0248... 0.00 seconds
Generating Field_0249... 0.00 seconds
Generating Field_0250... 0.00 seconds
Generating Field_0251... 0.00 seconds
Generating Field_0252... 0.00 seconds
Generating Field_0253... 0.00 seconds
Generating Field_0254... 0.00 seconds
Generating Field_0255... 0.00 seconds
Generating Field_0256... 0.00 seconds
Generating Field_0257... 0.00 seconds
Generating Field_0258... 0.00 seconds
Generating Field_0259... 0.00 seconds
Generating Field_0260... 0.00 seconds
Generating Field_0261... 0.00 seconds
Generating Field_0262... 0.00 seconds
Generating Field_0263... 0.00 seconds
Generating Field_0264... 0.00 seconds
Generating Field_0265... 0.00 seconds
Generating Field_0266... 0.00 seconds
Generating Field_0267... 0.00 seconds
Generating Field_0268... 0.00 seconds
Generating Field_0269... 0.00 seconds
Generating Field_0270... 0.00 seconds
Generating Field_0271... 0.00 seconds
Generating Field_0272... 0.00 seconds
Generating Field_0273... 0.00 seconds
Generating Field_0274... 0.00 seconds
Generating Field_0275... 0.00 seconds
Generating Field_0276... 0.00 seconds
Generating Field_0277... 0.00 seconds
Generating Field_0278... 0.00 seconds
Generating Field_0279... 0.00 seconds
Generating Field_0280... 0.00 seconds
Generating Field_0281... 0.00 seconds
Generating Field_0282... 0.00 seconds
Generating Field_0283... 0.00 seconds
Generating Field_0284... 0.00 seconds
Generating Field_0285... 0.00 seconds
Generating Field_0286... 0.00 seconds
Generating Field_0287... 0.00 seconds
Generating Field_0288... 0.00 seconds
Generating Field_0289... 0.00 seconds
Generating Field_0290... 0.00 seconds
Generating Field_0291... 0.00 seconds
Generating Field_0292... 0.00 seconds
Generating Field_0293... 0.00 seconds
Generating Field_0294... 0.00 seconds
Generating Field_0295... 0.00 seconds
Generating Field_0296... 0.00 seconds
Generating Field_0297... 0.00 seconds
Generating Field_0298... 0.00 seconds
Generating Field_0299... 0.00 seconds
Generating Field_0300... 0.00 seconds
Generating Field_0301... 0.00 seconds
Generating Field_0302... 0.00 seconds
Generating Field_0303... 0.00 seconds
Generating Field_0304... 0.00 seconds
Generating Field_0305... 0.00 seconds
Generating Field_0306... 0.00 seconds
Generating Field_0307... 0.00 seconds
Generating Field_0308... 0.00 seconds
Generating Field_0309... 0.00 seconds
Generating Field_0310... 0.00 seconds
Generating Field_0311... 0.00 seconds
Generating Field_0312... 0.00 seconds
Generating Field_0313... 0.00 seconds
Generating Field_0314... 0.00 seconds
Generating Field_0315... 0.00 seconds
Generating Field_0316... 0.00 seconds
Generating Field_0317... 0.00 seconds
Generating Field_0318... 0.00 seconds
Generating Field_0319... 0.00 seconds
Generating Field_0320... 0.00 seconds
Generating Field_0321... 0.00 seconds
Generating Field_0322... 0.00 seconds
Generating Field_0323... 0.00 seconds
Generating Field_0324... 0.00 seconds
Generating Field_0325... 0.00 seconds
Generating Field_0326... 0.00 seconds
Generating Field_0327... 0.00 seconds
Generating Field_0328... 0.00 seconds
Generating Field_0329... 0.00 seconds
Generating Field_0330... 0.00 seconds
Generating Field_0331... 0.00 seconds
Generating Field_0332... 0.00 seconds
Generating Field_0333... 0.00 seconds
Generating Field_0334... 0.00 seconds
Generating Field_0335... 0.00 seconds
Generating Field_0336... 0.00 seconds
Generating Field_0337... 0.00 seconds
Generating Field_0338... 0.00 seconds
Generating Field_0339... 0.00 seconds
Generating Field_0340... 0.00 seconds
Generating Field_0341... 0.00 seconds
Generating Field_0342... 0.00 seconds
Generating Field_0343... 0.00 seconds
Generating Field_0344... 0.00 seconds
Generating Field_0345... 0.00 seconds
Generating Field_0346... 0.00 seconds
Generating Field_0347... 0.00 seconds
Generating Field_0348... 0.00 seconds
Generating Field_0349... 0.01 seconds
Generating Field_0350... 0.00 seconds
Generating Field_0351... 0.00 seconds
Generating Field_0352... 0.00 seconds
Generating Field_0353... 0.00 seconds
Generating Field_0354... 0.00 seconds
Generating Field_0355... 0.00 seconds
Generating Field_0356... 0.00 seconds
Generating Field_0357... 0.00 seconds
Generating Field_0358... 0.00 seconds
Generating Field_0359... 0.00 seconds
Generating Field_0360... 0.00 seconds
Generating Field_0361... 0.00 seconds
Generating Field_0362... 0.00 seconds
Generating Field_0363... 0.00 seconds
Generating Field_0364... 0.00 seconds
Generating Field_0365... 0.00 seconds
Generating Field_0366... 0.00 seconds
Generating Field_0367... 0.00 seconds
Generating Field_0368... 0.00 seconds
Generating Field_0369... 0.00 seconds
Generating Field_0370... 0.00 seconds
Generating Field_0371... 0.00 seconds
Generating Field_0372... 0.00 seconds
Generating Field_0373... 0.00 seconds
Generating Field_0374... 0.00 seconds
Generating Field_0375... 0.00 seconds
Generating Field_0376... 0.00 seconds
Generating Field_0377... 0.00 seconds
Generating Field_0378... 0.00 seconds
Generating Field_0379... 0.00 seconds
Generating Field_0380... 0.00 seconds
Generating Field_0381... 0.00 seconds
Generating Field_0382... 0.01 seconds
Generating Field_0383... 0.00 seconds
Generating Field_0384... 0.00 seconds
Generating Field_0385... 0.00 seconds
Generating Field_0386... 0.00 seconds
Generating Field_0387... 0.00 seconds
Generating Field_0388... 0.00 seconds
Generating Field_0389... 0.00 seconds
Generating Field_0390... 0.00 seconds
Generating Field_0391... 0.00 seconds
Generating Field_0392... 0.00 seconds
Generating Field_0393... 0.00 seconds
Generating Field_0394... 0.00 seconds
Generating Field_0395... 0.00 seconds
Generating Field_0396... 0.00 seconds
Generating Field_0397... 0.00 seconds
Generating Field_0398... 0.00 seconds
Generating Field_0399... 0.00 seconds
Generating Field_0400... 0.00 seconds
Generating Field_0401... 0.00 seconds
Generating Field_0402... 0.00 seconds
Generating Field_0403... 0.00 seconds
Generating Field_0404... 0.00 seconds
Generating Field_0405... 0.00 seconds
Generating Field_0406... 0.00 seconds
Generating Field_0407... 0.00 seconds
Generating Field_0408... 0.00 seconds
Generating Field_0409... 0.00 seconds
Generating Field_0410... 0.00 seconds
Generating Field_0411... 0.00 seconds
Generating Field_0412... 0.00 seconds
Generating Field_0413... 0.00 seconds
Generating Field_0414... 0.00 seconds
Generating Field_0415... 0.01 seconds
Generating Field_0416... 0.00 seconds
Generating Field_0417... 0.00 seconds
Generating Field_0418... 0.00 seconds
Generating Field_0419... 0.00 seconds
Generating Field_0420... 0.00 seconds
Generating Field_0421... 0.00 seconds
Generating Field_0422... 0.00 seconds
Generating Field_0423... 0.00 seconds
Generating Field_0424... 0.00 seconds
Generating Field_0425... 0.00 seconds
Generating Field_0426... 0.00 seconds
Generating Field_0427... 0.00 seconds
Generating Field_0428... 0.00 seconds
Generating Field_0429... 0.00 seconds
Generating Field_0430... 0.00 seconds
Generating Field_0431... 0.00 seconds
Generating Field_0432... 0.00 seconds
Generating Field_0433... 0.00 seconds
Generating Field_0434... 0.00 seconds
Generating Field_0435... 0.00 seconds
Generating Field_0436... 0.00 seconds
Generating Field_0437... 0.00 seconds
Generating Field_0438... 0.00 seconds
Generating Field_0439... 0.00 seconds
Generating Field_0440... 0.00 seconds
Generating Field_0441... 0.00 seconds
Generating Field_0442... 0.00 seconds
Generating Field_0443... 0.00 seconds
Generating Field_0444... 0.00 seconds
Generating Field_0445... 0.00 seconds
Generating Field_0446... 0.00 seconds
Generating Field_0447... 0.00 seconds
Generating Field_0448... 0.00 seconds
Generating Field_0449... 0.00 seconds
Generating Field_0450... 0.00 seconds
Generating Field_0451... 0.00 seconds
Generating Field_0452... 0.00 seconds
Generating Field_0453... 0.00 seconds
Generating Field_0454... 0.00 seconds
Generating Field_0455... 0.00 seconds
Generating Field_0456... 0.00 seconds
Generating Field_0457... 0.00 seconds
Generating Field_0458... 0.00 seconds
Generating Field_0459... 0.00 seconds
Generating Field_0460... 0.00 seconds
Generating Field_0461... 0.00 seconds
Generating Field_0462... 0.00 seconds
Generating Field_0463... 0.00 seconds
Generating Field_0464... 0.00 seconds
Generating Field_0465... 0.00 seconds
Generating Field_0466... 0.00 seconds
Generating Field_0467... 0.00 seconds
Generating Field_0468... 0.00 seconds
Generating Field_0469... 0.00 seconds
Generating Field_0470... 0.00 seconds
Generating Field_0471... 0.00 seconds
Generating Field_0472... 0.00 seconds
Generating Field_0473... 0.00 seconds
Generating Field_0474... 0.00 seconds
Generating Field_0475... 0.00 seconds
Generating Field_0476... 0.00 seconds
Generating Field_0477... 0.00 seconds
Generating Field_0478... 0.00 seconds
Generating Field_0479... 0.00 seconds
Generating Field_0480... 0.00 seconds
Generating Field_0481... 0.00 seconds
Generating Field_0482... 0.00 seconds
Generating Field_0483... 0.00 seconds
Generating Field_0484... 0.00 seconds
Generating Field_0485... 0.00 seconds
Generating Field_0486... 0.00 seconds
Generating Field_0487... 0.00 seconds
Generating Field_0488... 0.00 seconds
Generating Field_0489... 0.00 seconds
Generating Field_0490... 0.00 seconds
Generating Field_0491... 0.00 seconds
Generating Field_0492... 0.00 seconds
Generating Field_0493... 0.00 seconds
Generating Field_0494... 0.00 seconds
Generating Field_0495... 0.00 seconds
Generating Field_0496... 0.00 seconds
Generating Field_0497... 0.00 seconds
Generating Field_0498... 0.00 seconds
Generating Field_0499... 0.00 seconds
Compute the two averaged measures#
For every thresholds, the two average measures over all the realisations are compute and compared to the theoretical values.
# save average for every thresholds
totalLengthMC = numpy.zeros_like(thresholds)
eulerCharacMC = numpy.zeros_like(thresholds)
# coucou
# loop over the thresholds
for i, t in enumerate(thresholds):
# loop over the realisations
for r in realisations:
totalLengthMC[i] += length * spam.measurements.volume(r > t) / float(nRea * nNodes)
eulerCharacMC[i] += spam.measurements.eulerCharacteristic(r > t) / float(nRea)
# plot length
plt.figure()
plt.xlabel('Threshold')
plt.title('Total length')
plt.plot(thresholds, totalLength, 'r', label='Theory')
plt.plot(thresholds, totalLengthMC, '*b', label='Monte Carlo')
plt.legend()
# plot Euler characteristic
plt.figure()
plt.xlabel('Threshold')
plt.title('Euler characteristic')
plt.plot(thresholds, eulerCharac, 'r', label='Theory')
plt.plot(thresholds, eulerCharacMC, '*b', label='Monte Carlo')
plt.legend()
plt.show()
Total running time of the script: (0 minutes 3.267 seconds)