# Lab 0: Python Recap#

*For the class on Monday, January 8th*

## A. Gaussian distribution#

Generate 2,000 random numbers sampled from a standard Gaussian distribution.

Make a histogram of those numbers you generated from Step 1.

Overplot the probability density function (pdf) of a standard Gaussian distribution. Normalize the pdf appropriately so that it matches the histogram.

```
# Put your implementation for Part A here
```

### Post-implementation Questions - Part A#

What is the normalizing factor you have to use in Step 3? Can you determine its value a priori?

// Put your answers here

## B. Scatter Plot#

Read in this csv file.

Make a scatter plot for quantities

`x`

and`y`

. Use two different colors for entries with different`type`

values.For each type, calculate the Spearman correlation coefficient between

`x`

and`y`

.

```
# Put your implementation for Part B here
```

## C. Maze#

In this question, a maze is a 2d array with 1s and 0s, with 1 means walls and 0 means paths. The upper left (indices 0,0) and lower right (indices -1,-1) corners will always be 0.

A maze is solvable if there is a connected path (i.e., 0s) from the upper left corner to the lower right corner. Note that one cannot move diagonally in a maze.

Use

`generate_maze`

function (see below) to generate a maze.Visualize the maze as an image.

Determine if the maze is solvable using

`scipy.ndimage.label`

(Note: You only need to check whether the maze is solvable; you don’t need to find the solving path.)Repeat Steps 1 and 3 many times and estimate the probability of the maze being solvable.

Repeat Step 4 but with a different value of

`wall_prob`

when calling`generate_maze`

.

```
import numpy as np
def generate_maze(wall_prob=0.5, size=(100, 100), seed=None):
rng = np.random.default_rng(seed)
maze = (rng.random(size=size) < wall_prob).astype(np.int64)
maze[0,0] = maze[-1,-1] = 0
return maze
# Put your implementation for Part C here
```

### Post-implementation Questions - Part C#

How does the probability of the maze being solvable change with the value of

`wall_prob`

? Can you make a plot showing this dependence?// Put your answers here

(

*Optional*) How does the dependence you obtain in Q1 change with the maze size?// Put your answers here

Tip

**How to submit this notebook on Canvas?**

Once you complete this lab and have all your code, text answers, and all the desired results after running the notebook properly displayed in this notebook, please convert the notebook into HTML format by running the following:

```
jupyter nbconvert --to html /path/to/labs/00.ipynb
```

Then, upload the resulting HTML file to Canvas for the corresponding assignment.