0% found this document useful (0 votes)
50 views8 pages

SE 132 Machine Learning For Structural Engineering J. S. Chen Spring 2021 Homework #1 Part 1 (10 Points)

The document provides instructions for Homework 1 of the Machine Learning for Structural Engineering course. It includes 5 problems to solve related to systems of equations, probability distributions, conditional probability, and data analysis. It also provides instructions for installing Anaconda and Jupyter notebook to complete and submit the homework. Students are asked to create a Jupyter notebook named "SE132_SP21_HW1_YourName" and include code cells solving the problems and markdown cells with headings explaining the solutions.

Uploaded by

Alex Lin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views8 pages

SE 132 Machine Learning For Structural Engineering J. S. Chen Spring 2021 Homework #1 Part 1 (10 Points)

The document provides instructions for Homework 1 of the Machine Learning for Structural Engineering course. It includes 5 problems to solve related to systems of equations, probability distributions, conditional probability, and data analysis. It also provides instructions for installing Anaconda and Jupyter notebook to complete and submit the homework. Students are asked to create a Jupyter notebook named "SE132_SP21_HW1_YourName" and include code cells solving the problems and markdown cells with headings explaining the solutions.

Uploaded by

Alex Lin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

SE 132 Machine Learning for Structural Engineering J. S.

Chen
Spring 2021
Homework #1 Due April 6 (3:30 PM PST), 2021

Part 1 (10 Points)

1. Determine the values of  for which the following system has a non-trivial solution:

3x 1 + x 2 − x3 = 0
4x 1 − x 2 − 3x 3 = 0
2x1 + 3x 2 + x 3 = 0

2. Consider the following system of equations:

x1 + 2x2 = 1
x1 − x2 + x3 = 4
3x2 − x3 = c

(1) For what value of c does a solution exist?


(2) If a solution exists, is it unique?
(3) For value of c for which a solution exists, find all solutions.

3. Given a fair 6-sided dice that can take 6 possible outcomes {1,2,3,4,5,6}, let’s throw the dice
twice and define a random variable 𝑋 to tell how many 6 we can obtain. Show the probability
distribution of 𝑋, that is, the probabilities of all possible outcomes of 𝑋: 𝑃(𝑋 = 0), 𝑃(𝑋 = 1),
𝑃(𝑋 = 2). What is the expectation, variance, and standard deviation of 𝑋?

4. Given two fair coins (with a head and a tail), let 𝐻𝑖 denote “coin 𝑖 is head” and ∃𝐻 denote “at
least one head”. What is the conditional probability 𝑃(𝐻1 |∃𝐻)?

5. Given a vector, 𝒙 = [6, 2, 3, 5], calculate its mean 𝜇𝒙 and standard deviation 𝜎𝒙 . Standardize 𝒙
̂ = (𝒙 − 𝜇𝒙 )/𝜎𝒙 . What is the mean 𝜇𝒙̂ and standard deviation 𝜎𝒙̂ of the standardized vector 𝒙
by 𝒙 ̂?

1
Part 2 (10 Points)

Follow the instructions to install Anaconda, complete the problems under your Jupyter
notebook and submit it (named as “SE132_SP21_HW1_YourName”) to Gradescope.

Install Anaconda
You need to install the requisite programs that you will use in this course. Fortunately, you just
have to download one package from the internet which is Anaconda. You can find it at:
https://www.anaconda.com/products/individual

1) Click on Download as shown in the image below.

2
2) Install the latest version for your respective OS.

Installation tutorial: https://www.youtube.com/watch?v=5mDYijMfSzs

Create a Jupyter Notebook


1) Launch Jupyter notebook
• Approach 1: via Anaconda Navigator

3
• Approach 2: via Anaconda Prompt

4
Type “jupyter notebook” and Enter.

2) Create a new Jupyter notebook


A window should open in your default browser as in the image below. The menu list shows
the folders of the default drive in your machine.
• Navigate to the folder where you want the notebook to be stored.
• On the right-hand side, click on New → Python 3.

3) Rename and save the Jupyter notebook


• Rename the notebook as “SE132_SP21_HW1_YourName” through File → Rename or
click on the current file name at the top, which is “Untitled5” in this example.

5
• To save it, go to File → Save as or press ‘Ctrl’ + ‘s’. A file
“SE132_SP21_HW1_YourName.ipynb” will be saved in the directory where the
Jupyter notebook was created.

4) What is a Jupyter notebook? A Jupyter notebook is a collection of cells.


• There are mainly two types of cells:
o Code cells: Execute Python code
o Markdown cells: Display formatted texts or images
• Each cell has two modes:
o Edit mode: highlighted by green outline; To edit cells, click on the typing box of
the cells or double click on the cells.
o Command mode: highlighted by blue outline; To convert cells to the esc mode,
press the ‘esc’ key.
• To switch cells between Code and Markdown, the cells need to be in the command
mode.
o Press ‘y’ to convert Markdown cells to Code cells
o Press ‘m’ to convert Code cells to Markdown cells

5) Create Code cells


• Print “hello world!”

6
• Print the value of variables or expressions:

6) Create Markdown cells


• Type “# hello world!” in the created Markdown cell

Execute the Markdown cell by 'Ctrl' + 'Enter'

• Type “## hello world!” in the created Markdown cell

Execute the Markdown cell by 'Ctrl' + 'Enter'

• Type “### hello world!” in the created Markdown cell

Execute the Markdown cell by 'Ctrl' + 'Enter'

• Above show that the number of # determines the level of headings


• More information about how to format text in Markdown cells can be found in
https://www.datacamp.com/community/tutorials/markdown-in-jupyter-notebook

7
7) Practice the following commonly used commands
• Navigate between cells: press ‘up’ or ‘down’ arrow keys, or use the cursor to select
cells
• Create a cell below the current one: press ‘b’
• Create a cell above the current one: press ‘a’
• Delete a cell: press ‘dd’
• Execute the current cell: press 'Ctrl' + 'Enter'
• Execute the current cell and select the cell below: press 'Shift' + 'Enter'
• Execute all cells in the notebook: click on ‘Cell’ (in the top menu) > ‘Run All’
• Execute all cells Above the current cell: click on ‘Cell’ (in the top menu) > ‘Run
All Above’
• Execute all cells Below the current cell: click on ‘Cell’ (in the top menu) > ‘Run All
Below

8) Follow the Python tutorial in the Jupyter notebook of Lab 1 and complete the following
exercises.
• Create variables of basic data types discussed in the tutorial, including Numbers,
Booleans, Strings; Print the values and data type of these variables
• Create variables of data containers discussed in the tutorial, including Lists,
Dictionaries, Sets, and Tuples; Print the values of these variables
• Create a function that multiplies all elements of a given list by 5; Call the function
with the list [2, 5, 10, 3, 7] and print the resulting list.

You might also like