{
"cells": [
{
"cell_type": "markdown",
"id": "269c4188",
"metadata": {},
"source": [
"# Exercise sheet\n",
"\n",
"Some general remarks about the exercises:\n",
"* For your convenience functions from the lecture are included below. Feel free to reuse them without copying to the exercise solution box.\n",
"* For each part of the exercise a solution box has been added, but you may insert additional boxes. Do not hesitate to add Markdown boxes for textual or LaTeX answers (via `Cell > Cell Type > Markdown`). But make sure to replace any part that says `YOUR CODE HERE` or `YOUR ANSWER HERE` and remove the `raise NotImplementedError()`.\n",
"* Please make your code readable by humans (and not just by the Python interpreter): choose informative function and variable names and use consistent formatting. Feel free to check the [PEP 8 Style Guide for Python](https://www.python.org/dev/peps/pep-0008/) for the widely adopted coding conventions or [this guide for explanation](https://realpython.com/python-pep8/).\n",
"* Make sure that the full notebook runs without errors before submitting your work. This you can do by selecting `Kernel > Restart & Run All` in the jupyter menu.\n",
"* For some exercises test cases have been provided in a separate cell in the form of `assert` statements. When run, a successful test will give no output, whereas a failed test will display an error message.\n",
"* Each sheet has 100 points worth of exercises. Note that only the grades of sheets number 2, 4, 6, 8 count towards the course examination. Submitting sheets 1, 3, 5, 7 & 9 is voluntary and their grades are just for feedback.\n",
"\n",
"Please fill in your name here:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "220d541e",
"metadata": {},
"outputs": [],
"source": [
"NAME = \"\"\n",
"NAMES_OF_COLLABORATORS = \"\""
]
},
{
"cell_type": "markdown",
"id": "b6944e4c",
"metadata": {},
"source": [
"---"
]
},
{
"cell_type": "markdown",
"id": "c53fbab6",
"metadata": {
"deletable": false,
"editable": false,
"nbgrader": {
"cell_type": "markdown",
"checksum": "da0f2845f08ee29eb0450f8eff343e98",
"grade": false,
"grade_id": "cell-3cb26b1434512d8d",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"source": [
"**Exercise sheet 8**\n",
"\n",
"Code from the lectures:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5e4391a6",
"metadata": {
"deletable": false,
"editable": false,
"nbgrader": {
"cell_type": "code",
"checksum": "1814f5ba5f2d71b14a4c534cfe3ad7ff",
"grade": false,
"grade_id": "cell-40c62687f6a2c579",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"outputs": [],
"source": [
"import numpy as np\n",
"rng = np.random.default_rng() \n",
"import matplotlib.pylab as plt\n",
"%matplotlib inline\n",
"\n",
"def fan_triangulation(n):\n",
" '''Generates a fan-shaped triangulation of even size n.'''\n",
" return np.array([[(i-3)%(3*n),i+5,i+4,(i+6)%(3*n),i+2,i+1] \n",
" for i in range(0,3*n,6)],dtype=np.int32).flatten()\n",
"\n",
"def is_fpf_involution(adj):\n",
" '''Test whether adj defines a fixed-point free involution.'''\n",
" for x, a in enumerate(adj):\n",
" if a < 0 or a >= len(adj) or x == a or adj[a] != x:\n",
" return False\n",
" return True\n",
"\n",
"from collections import deque \n",
"\n",
"def triangle_neighbours(adj,i):\n",
" '''Return the indices of the three neighboring triangles.'''\n",
" return [j//3 for j in adj[3*i:3*i+3]]\n",
"\n",
"def connected_components(adj):\n",
" '''Calculate the number of connected components of the triangulation.'''\n",
" n = len(adj)//3 # the number of triangles\n",
" # array storing the component index of each triangle\n",
" component = np.full(n,-1,dtype=np.int32) \n",
" index = 0\n",
" for i in range(n):\n",
" if component[i] == -1: # new component found, let us explore it\n",
" component[i] = index\n",
" queue = deque([i]) # use an exploration queue for breadth-first search\n",
" while queue:\n",
" for nbr in triangle_neighbours(adj,queue.pop()):\n",
" # the neighboring triangle has not been explored yet\n",
" if component[nbr] == -1: \n",
" component[nbr] = index\n",
" queue.appendleft(nbr) # add it to the exploration queue\n",
" index += 1\n",
" return index\n",
"\n",
"def next_around_triangle(i):\n",
" '''Return the label of the side following side i in counter-clockwise direction.'''\n",
" return i - i%3 + (i+1)%3\n",
"\n",
"def prev_around_triangle(i):\n",
" '''Return the label of the side preceding side i in counter-clockwise direction.'''\n",
" return i - i%3 + (i-1)%3\n",
"\n",
"def vertex_list(adj):\n",
" '''\n",
" Return the number of vertices and an array `vertex` of the same size \n",
" as `adj`, such that `vertex[i]` is the index of the vertex at the \n",
" start (in ccw order) of the side labeled `i`.\n",
" '''\n",
" # a side i that have not been visited yet has vertex[i]==-1\n",
" vertex = np.full(len(adj),-1,dtype=np.int32) \n",
" vert_index = 0 \n",
" for i in range(len(adj)):\n",
" if vertex[i] == -1:\n",
" side = i\n",
" while vertex[side] == -1: # find all sides that share the same vertex\n",
" vertex[side] = vert_index\n",
" side = next_around_triangle(adj[side])\n",
" vert_index += 1\n",
" return vert_index, vertex\n",
"\n",
"def number_of_vertices(adj):\n",
" '''Calculate the number of vertices in the triangulation.'''\n",
" return vertex_list(adj)[0]\n",
"\n",
"def is_sphere_triangulation(adj):\n",
" '''Test whether adj defines a triangulation of the 2-sphere.'''\n",
" if not is_fpf_involution(adj) or connected_components(adj) != 1:\n",
" return False\n",
" num_vert = number_of_vertices(adj)\n",
" num_face = len(adj)//3\n",
" num_edge = len(adj)//2\n",
" # verify Euler's formula for the sphere\n",
" return num_vert - num_edge + num_face == 2\n",
"\n",
"def flip_edge(adj,i):\n",
" if adj[i] == next_around_triangle(i) or adj[i] == prev_around_triangle(i):\n",
" # flipping an edge that is adjacent to the same triangle on both sides makes no sense\n",
" return False\n",
" j = prev_around_triangle(i)\n",
" k = adj[i]\n",
" l = prev_around_triangle(k)\n",
" n = adj[l]\n",
" adj[i] = n # it is important that we first update\n",
" adj[n] = i # these adjacencies, before determining m,\n",
" m = adj[j] # to treat the case j == n appropriately\n",
" adj[k] = m\n",
" adj[m] = k\n",
" adj[j] = l\n",
" adj[l] = j\n",
" return True\n",
"\n",
"def random_flip(adj):\n",
" random_side = rng.integers(0,len(adj))\n",
" return flip_edge(adj,random_side)\n",
"\n",
"import networkx as nx\n",
"from mpl_toolkits.mplot3d import Axes3D\n",
"from mpl_toolkits.mplot3d.art3d import Poly3DCollection\n",
"\n",
"def triangulation_edges(triangulation,vertex):\n",
" '''Return a list of vertex-id pairs corresponding to the edges in the triangulation.'''\n",
" return [(vertex[i],vertex[j]) for i,j in enumerate(triangulation) if i < j]\n",
"\n",
"def triangulation_triangles(triangulation,vertex):\n",
" '''Return a list of vertex-id triples corresponding to the triangles in the triangulation.'''\n",
" return [vertex[i:i+3] for i in range(0,len(triangulation),3)]\n",
"\n",
"def plot_triangulation_3d(adj):\n",
" '''Display an attempt at embedding the triangulation in 3d.'''\n",
" num_vert, vertex = vertex_list(adj)\n",
" edges = triangulation_edges(adj,vertex)\n",
" triangles = triangulation_triangles(adj,vertex)\n",
" # use the networkX 3d graph layout algorithm to find positions for the vertices\n",
" pos = np.array(list(nx.spring_layout(nx.Graph(edges),dim=3).values()))\n",
" fig = plt.figure()\n",
" ax = fig.add_subplot(111, projection='3d')\n",
" tris = Poly3DCollection(pos[triangles])\n",
" tris.set_edgecolor('k')\n",
" ax.add_collection3d(tris)\n",
" ax.set_xlim3d(np.amin(pos[:,0]),np.amax(pos[:,0]))\n",
" ax.set_ylim3d(np.amin(pos[:,1]),np.amax(pos[:,1]))\n",
" ax.set_zlim3d(np.amin(pos[:,2]),np.amax(pos[:,2]))\n",
" plt.show()\n",
" \n",
"def vertex_neighbors_list(adj):\n",
" '''Return a list `neighbors` such that `neighbors[v]` is a list of neighbors of the vertex v.'''\n",
" num_vertices, vertex = vertex_list(adj)\n",
" neighbors = [[] for _ in range(num_vertices)]\n",
" for i,j in enumerate(adj):\n",
" neighbors[vertex[i]].append(vertex[j])\n",
" return neighbors\n",
"\n",
"def vertex_distance_profile(adj,max_distance=30):\n",
" '''Return array `profile` of size `max_distance` such that `profile[r]` is the number\n",
" of vertices that have distance r to a randomly chosen initial vertex.'''\n",
" profile = np.zeros((max_distance),dtype=np.int32)\n",
" neighbors = vertex_neighbors_list(adj)\n",
" num_vertices = len(neighbors)\n",
" start = rng.integers(num_vertices) # random starting vertex\n",
" distance = np.full(num_vertices,-1,dtype=np.int32) # array tracking the known distances (-1 is unknown)\n",
" queue = deque([start]) # use an exploration queue for the breadth-first search\n",
" distance[start] = 0\n",
" profile[0] = 1 # of course there is exactly 1 vertex at distance 0\n",
" while queue:\n",
" current = queue.pop()\n",
" d = distance[current] + 1 # every unexplored neighbour will have this distance\n",
" if d >= max_distance:\n",
" break\n",
" for nbr in neighbors[current]:\n",
" if distance[nbr] == -1: # this neighboring vertex has not been explored yet\n",
" distance[nbr] = d\n",
" profile[d] += 1\n",
" queue.appendleft(nbr) # add it to the exploration queue\n",
" return profile\n",
" \n",
"def perform_sweeps(adj,t):\n",
" '''Perform t sweeps of flip moves, where 1 sweep is N moves.'''\n",
" for _ in range(len(adj)*t//3):\n",
" random_flip(adj)\n",
"\n",
"def batch_estimate(data,observable,k):\n",
" '''Devide data into k batches and apply the function observable to each.\n",
" Returns the mean and standard error.'''\n",
" batches = np.reshape(data,(k,-1))\n",
" values = np.apply_along_axis(observable, 1, batches)\n",
" return np.mean(values), np.std(values)/np.sqrt(k-1)"
]
},
{
"cell_type": "markdown",
"id": "bed55184",
"metadata": {
"deletable": false,
"editable": false,
"nbgrader": {
"cell_type": "markdown",
"checksum": "8c9a6c198119d4649dd87308e8933611",
"grade": false,
"grade_id": "cell-5f5adc7840fea9ad",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"source": [
"## Estimating Hausdorff dimensions in various 2D quantum gravity models \n",
"\n",
"**(100 Points)**\n",
"\n",
"In the lecture we considered the model of two-dimensional Dynamical Triangulations of the 2-sphere. The corresponding partition function is\n",
"\n",
"$$\n",
"Z^{U}_{S^2,N} = \\sum_T 1, \\qquad\\qquad(1)\n",
"$$\n",
"\n",
"where the sum is over all triangulations of size $N$ with the topology of $S^2$, each of which is represented as an adjacency list $\\operatorname{adj}: \\{0,\\ldots,3N-1\\} \\to \\{0,\\ldots,3N-1\\}$. To emphasize that we are dealing with the **uniform** probability distribution on such triangulations, we have added the label $^U$. It is a lattice model of two-dimensional Euclidean quantum gravity with no coupled matter.\n",
"\n",
"One can also consider two-dimensional quantum gravity coupled to matter fields (e.g. a scalar field) supported on the geometry. Formally the corresponding path integral in the continuum reads\n",
"\n",
"$$ \n",
"Z = \\int [\\mathcal{D}g_{ab}]\\int [\\mathcal{D}\\phi] e^{-\\frac{1}{\\hbar}(S_E[g_{ab}] + S_m[\\phi,g_{ab}])} = \\int [\\mathcal{D}g_{ab}]e^{-\\frac{1}{\\hbar}S_E[g_{ab}]} Z^*_m[g_{ab}],\n",
"$$\n",
"\n",
"where $S_m[\\phi,g_{ab}]$ and $Z_m[g_{ab}]$ are the matter action and path integral of the field $\\phi$ on the geometry described by $g_{ab}$. The natural analogue in Dynamical Triangulations is\n",
"\n",
"$$\n",
"Z^*_{S^2,N} = \\sum_T Z^*_m[T],\n",
"$$\n",
"\n",
"where the sum is over the same triangulations as in (1) but now the summand $Z^*_m[T]$ is the lattice partition function of a matter system supported on the triangulation $T$, which generically depends in a non-trivial way on $T$. For instance, the matter system could be an Ising model in which the spin are supported on the triangles of $T$ and $Z^{\\text{Ising}}_m[T]$ would be the corresponding Ising partition function.\n",
"In other words, when Dynamical Triangulations are coupled to matter the uniform distribution $\\pi^U(T) = 1/Z^U_{S^2,N}$ is changed into a non-uniform distribution $\\pi^*(T) = Z^*_m[T] / Z^*_{S^2,N}$. This can have significant effect on the critical exponents of the random triangulation as $N\\to\\infty$, like the Hausdorff dimension. \n",
"\n",
"The goal of this exercise is to estimate the **Hausdorff dimension** of random triangulations in four different models and to conclude based on this that they belong to four different universality classes (i.e. that if they possess well-defined continuum limits that they are described by four different EQFTs): \n",
"* $Z^{U}_{S^2,N}$: the standard Dynamical Triangulations with **U**niform distribution (U)\n",
"* $Z^{W}_{S^2,N}$: triangulations coupled to a matter system called a Schnyder **W**ood (W)\n",
"* $Z^{S}_{S^2,N}$: triangulations coupled to a matter system called a **S**panning tree (S)\n",
"* $Z^{B}_{S^2,N}$: triangulations coupled to a matter system called a **B**ipolar orientation (B)\n",
"\n",
"What these matter systems precisely represent will not be important. We have provided for you a **black box generator** that samples from the corresponding four distributions $\\pi^U(T)$, $\\pi^W(T)$, $\\pi^S(T)$, $\\pi^B(T)$. It does so in an efficient manner (linear time in $N$) using direct Monte Carlo sampling algorithms and therefore returns independent samples with exactly the desired distribution $\\pi^*(T)$ (within numerical precision).\n",
"\n",
"The black box generator is provided by the executable program `generator` provided to you on the science server. It can be called directly from this notebook with the following function `generate_random_triangulation`, that takes the desired size $N$ and model (`'U'`,`'W'`, `'S'`, `'B'`) and returns a single random triangulation in the usual form of an adjacency list."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "bcc7acba",
"metadata": {
"deletable": false,
"editable": false,
"nbgrader": {
"cell_type": "code",
"checksum": "7d6abad00aa217998ca44ecc5e89f423",
"grade": false,
"grade_id": "cell-266ff66f880583d7",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"outputs": [],
"source": [
"import subprocess\n",
"\n",
"def generate_random_triangulation(n,model):\n",
" '''\n",
" Returns a random triangulation generated by the program `generator` in the form \n",
" of an array of length 3n storing the adjacency information of the triangle sides.\n",
" Parameters:\n",
" n - number of triangles in the triangulation, must be positive and even\n",
" model - a one-letter string specifying the model from which the triangulation is sampled:\n",
" 'U': Uniform triangulations\n",
" 'W': Schnyder-Wood-decorated triangulations\n",
" 'S': Spanning-tree decorated triangulations\n",
" 'B': Bipolar-oriented triangulations\n",
" '''\n",
" program = \"/vol/cursus/NM042B/bin/generator\"\n",
" output = subprocess.check_output([program,\"-s{}\".format(n),\"-t{}\".format(model)]).decode('ascii').split('\\n')[:-1]\n",
" return np.array([int(num) for num in output],dtype=np.int32)\n",
"\n",
"adj = generate_random_triangulation(100,'B')\n",
"is_sphere_triangulation(adj)"
]
},
{
"cell_type": "markdown",
"id": "4518f51f",
"metadata": {
"deletable": false,
"editable": false,
"nbgrader": {
"cell_type": "markdown",
"checksum": "37e92f3a59f2d5c6d117868d04d8f0d4",
"grade": false,
"grade_id": "cell-6aacf5fa6d8c4eb9",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"source": [
"Recall that the **distance profile** $\\rho_T(r)$ of a triangulation is defined as \n",
"\n",
"$$ \n",
"\\rho_T(r) = \\frac{1}{V} \\sum_{x=0}^{V-1} \\sum_{y=0}^{V-1} \\mathbf{1}_{\\{d_T(x,y)=r\\}},\n",
"$$\n",
"\n",
"where $V = (N+4)/2$ is the number of vertices and $d_T(x,y)$ is the graph distance between the vertices with label $x$ and $y$."
]
},
{
"cell_type": "markdown",
"id": "d59143f0",
"metadata": {
"deletable": false,
"editable": false,
"nbgrader": {
"cell_type": "markdown",
"checksum": "afcdbf86f64bd17b8ac9b4f9ec422206",
"grade": false,
"grade_id": "cell-8e6d6fcefb5ab644",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"source": [
"**(a)** Let $T$ be a random triangulation of size $N$ and $X$, $Y$ two independent numbers chosen uniformly from $0,\\ldots,V-1$, corresponding to two random vertices in $T$. Explain with a calculation that $\\frac{1}{V}\\mathbb{E}[ \\rho_T(r) ] = \\mathbb{P}(d_T(X,Y) = r)$ and that the expected distance between $X$ and $Y$ is related to the distance profile via\n",
"\n",
"$$\n",
"\\mathbb{E}[d_T(X,Y)] = \\frac{1}{V}\\sum_{r=0}^\\infty r\\, \\mathbb{E}[ \\rho_T(r) ]. \\qquad\\qquad(2)\n",
"$$\n",
"\n",
"**(20 pts)**"
]
},
{
"cell_type": "markdown",
"id": "dd1b43bf",
"metadata": {
"deletable": false,
"nbgrader": {
"cell_type": "markdown",
"checksum": "74963ed3d7cbd9eaa06be2e66a8f939e",
"grade": true,
"grade_id": "cell-f86454063d193cd6",
"locked": false,
"points": 20,
"schema_version": 3,
"solution": true,
"task": false
}
},
"source": [
"YOUR ANSWER HERE"
]
},
{
"cell_type": "markdown",
"id": "29704f5d",
"metadata": {
"deletable": false,
"editable": false,
"nbgrader": {
"cell_type": "markdown",
"checksum": "e2cc0493d54bcf087ce14bcb2e8a8d2f",
"grade": false,
"grade_id": "cell-aafca9797e5cfee4",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"source": [
"**(b)** We will work under the assumption that \n",
"\n",
"$$\n",
"\\mathbb{E}[\\rho_T(r)] \\approx V^{1-1/d_H} f(r V^{-1/d_H})\n",
"$$ \n",
"\n",
"for a positive real number $d_H$ called the **Hausdorff dimension** and a continuous function $f$ that are both independent of $N$ but do depend on the model. Show that \n",
"\n",
"$$\n",
"\\mathbb{E}[d_T(X,Y)] \\approx c\\,V^{1/d_H}, \\qquad c = \\int_0^\\infty \\mathrm{d}x\\,x\\,f(x). \\qquad\\qquad(3)\n",
"$$\n",
"\n",
"_Hint:_ Approximate the summation by an integral. **(15 pts)**"
]
},
{
"cell_type": "markdown",
"id": "0c062ba6",
"metadata": {
"deletable": false,
"nbgrader": {
"cell_type": "markdown",
"checksum": "2db525e8acbc2412c1c5948052526a15",
"grade": true,
"grade_id": "cell-bcf3b38d64a4408d",
"locked": false,
"points": 15,
"schema_version": 3,
"solution": true,
"task": false
}
},
"source": [
"YOUR ANSWER HERE"
]
},
{
"cell_type": "markdown",
"id": "eba53e6d",
"metadata": {
"deletable": false,
"editable": false,
"nbgrader": {
"cell_type": "markdown",
"checksum": "ba14acd8cc24c2dfea35f3b8106cdfc8",
"grade": false,
"grade_id": "cell-fcab32195688a5c5",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"source": [
"**(c)** For each of the four models estimate $\\mathbb{E}[d_T(X,Y)]$ with errors for $N = 2^7, 2^8, \\ldots, 2^{12}$ using (2) and based on $100$ samples each. Store your data in the file `qgdimension.hdf5`. Make an estimate of $d_H$ (with errors) for each of the models by fitting the parameters $c$ and $d_H$ of the ansatz (3). For each model, plot the data together with the fit in a log-log plot. **(40 pts)**"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ee683060",
"metadata": {
"deletable": false,
"nbgrader": {
"cell_type": "code",
"checksum": "c3664034dec3a350f7fe0533fe2454cb",
"grade": true,
"grade_id": "cell-01f5fde55f35f2dc",
"locked": false,
"points": 15,
"schema_version": 3,
"solution": true,
"task": false
}
},
"outputs": [],
"source": [
"models = ['U','W','S','B']\n",
"sizes = [2**k for k in range(7,13)]\n",
"num_vertices = (np.array(sizes)+4)/2\n",
"measurements = 100\n",
"\n",
"# data gathering and storing in qgdimension.hdf5\n",
"# YOUR CODE HERE\n",
"raise NotImplementedError()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "351f7a01",
"metadata": {
"deletable": false,
"nbgrader": {
"cell_type": "code",
"checksum": "000725107fe51acebc0bc68eef8c1c9c",
"grade": true,
"grade_id": "cell-9e8f666073e1e2df",
"locked": false,
"points": 25,
"schema_version": 3,
"solution": true,
"task": false
}
},
"outputs": [],
"source": [
"# Fitting and plotting\n",
"# YOUR CODE HERE\n",
"raise NotImplementedError()"
]
},
{
"cell_type": "markdown",
"id": "b505b3cf",
"metadata": {
"deletable": false,
"editable": false,
"nbgrader": {
"cell_type": "markdown",
"checksum": "be7888d11d6b9ca0f2666739857578cb",
"grade": false,
"grade_id": "cell-032c7f8d6147d9f9",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"source": [
"**(d)** Produce a *collapse* plot for each of the four models as follows: plot \n",
"\n",
"$$\n",
"V^{1/d_H}\\,\\mathbb{E}[\\frac{1}{V}\\rho_T(r)] \\quad\\text{ as function of } x = r / V^{1/d_H},\n",
"$$ \n",
"\n",
"where for $d_H$ you take the estimate obtained in the previous exercise. Show errors in the mean distance profiles via shaded regions (just like in the lecture). Verify that the curves collapse reasonably well. **(25 pts)**"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "988bfe95",
"metadata": {
"deletable": false,
"nbgrader": {
"cell_type": "code",
"checksum": "7b7eceb7923231bc3710d4e3036265b6",
"grade": true,
"grade_id": "cell-faf328e7505cf6a2",
"locked": false,
"points": 25,
"schema_version": 3,
"solution": true,
"task": false
}
},
"outputs": [],
"source": [
"# YOUR CODE HERE\n",
"raise NotImplementedError()"
]
},
{
"cell_type": "markdown",
"id": "d8f25787",
"metadata": {
"deletable": false,
"editable": false,
"nbgrader": {
"cell_type": "markdown",
"checksum": "7f19410ed936f838773ee891b059d1a3",
"grade": false,
"grade_id": "cell-65ae9c46ece5b657",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"source": [
"**(e) Bonus exercise:** Make more robust estimates of $d_H$ by optimizing the quality of the collapse. You could do this (for each model separately) by taking $\\hat{f}(r) = \\mathbb{E}[\\rho_T(r)] / V_0$, where the right-hand side is the mean distance profile for the largest system size with $V_0 = (2^{12} + 4)/2$ vertices. Then according to our assumption, for another size $V \\leq V_0$ we expect $\\mathbb{E}[\\rho_T(r)] / V \\approx k \\hat{f}(kr)$, where $k \\geq 1$ is a scale factor that should be $k\\approx (V_0/V)^{1/d_H}$. Making sure to interpolate the function $\\hat{f}(r)$ (using [`scipy.interpolate.interp1d`](https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.interp1d.html#scipy.interpolate.interp1d)), this scale factor can be determined by fitting the curve $k \\hat{f}(kr)$ to the data $\\mathbb{E}[\\rho_T(r)] / V$. Then $d_H$ can be estimated by fitting $k$ versus $V$. **(20 bonus points, but note that maximum grade is 10)**"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ed4424ce",
"metadata": {
"deletable": false,
"nbgrader": {
"cell_type": "code",
"checksum": "199ffddc14c77d4174b92a61368cd5c9",
"grade": true,
"grade_id": "cell-e24b0602e4e8257d",
"locked": false,
"points": 20,
"schema_version": 3,
"solution": true,
"task": false
}
},
"outputs": [],
"source": [
"# YOUR CODE HERE\n",
"raise NotImplementedError()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c9e50c10",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.8.10 64-bit",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
},
"vscode": {
"interpreter": {
"hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6"
}
}
},
"nbformat": 4,
"nbformat_minor": 5
}