Horizontal Rule In Jupyter Notebook



These are lecture notes and homeworks for a course taught at theUniversity of Rochester by Andrew White in the Chemical EngineeringDepartment. The course is taught using Jupyter Notebooks.

View the course online: whitead.github.io/numerical_stats/

Course Description

This course provides an introduction to numerical methods andengineering statistics for chemical engineers. Students learn to usecomputer models and statistics to understand engineering systems. Thefocus of numerical methods is translating engineering problems intonalgorithms and implementing them in a spreadsheet or programminglanguage. Topics covered include basic data structures, programmingflow control, plotting, function minimization, integration anddifferential equations. The statistics portion teaches students basicprobability theory, the central limit theorem, hypothesis testing,confidence intervals, regression, model fitting and basic erroranalysis.

Q02.14 Recreate two horizontal rules in a Jupyter notebook markdown cell. In between the horizontal rules write the text In between the lines like below: In between the lines. Q02.15 Inside a Jupyter notebook markdown cell, make the word Red the color red. Welcome to your first Jupyter notebook. Jupyter notebooks are documents that contain both computer code (like Python) alongside explanatory images, figures, videos, and links.Most importantly, the code in a Jupyter notebook can be executed, modified, and deleted. As you explore this notebook, please feel free to modify the text, the code, and to generally play around with the. Collaborate, create interactive visualizations, and manipulate big data in the language of your choice.

Matplotlib is a Python package for 2D plotting and the matplotlib.pyplot sub-module contains many plotting functions to create various kinds of plots. Let's get started by importing matplotlib.pyplot and using%matplotlib Jupyter magic to display plots in the notebook. Markdown for Jupyter notebooks cheatsheet. You can use Markdown to format documentation you add to Markdown cells in your Jupyter notebook. Horizontal lines On a new line, enter three asterisks:. Internal links To link to a section within your notebook, use the following code.

Projects

See project folder.

Table of Contents

Unit 1 — Introduction

Lecture 1: Sample Spaces, Probability Algebra of Samples, Events

Unit 2 — Probability

Lecture 1: Combinations & Permutations, Multidimensional Sample Spaces, Random Variables, Continuous Probability Distributions

Lecture 2: Marginals, Joints, Independence of Random Variables, Table of Useful Equations

Lecture 3: Conditionals, Working with Joints/Marginals/Conditionals, Bayes’ Theorem, Math Definition Independence, Compound Conditionals, Conditional Independence, Table of Useful Equations

Unit 3 — Python Basics

Lecture 1: Python Variables, String Formatting, Representing Integers

Lecture 2: Floating Point Representation, Python Booleans, Default Booleans, Floating Point Booleans, Lists, Slicing

Unit 4 — Python Basics, Expected Value

Lecture 1: List Methods, Range, Numpy Arrays, Python Tutor, For loops, Python Data Types (dictionaries, tuples, ints, floats), Function Arguments, Basic Plotting, Jupter Notebook Format

Lecture 2: Expected Values and Variance, Conditional Expectation

Unit 5 — Probability Distributions

Lecture 1: Bernoulli, Geometric, Binomial, Poisson, Exponential and Normal Distribution Equations

Lecture 2: Probability of a Sample or Interval, Prediction Interval

Unit 6 — Python Program Flow

Lecture 1: Plotting - Basics, LaTeX, Point Markers, Vertical/Horizontal Lines, Legends

Lecture 2: Break Statement, While Loops, Discrete Distribution Prediction Intervals, Scipy Stats, Working with Probability and Prediction Intervals of Normal Distribution

Lecture 3: Defining Functions, Named Arguments, Default Function Arguments, Documenting Functions,

Unit 7 — Functions and Sample Statistics

Lecture 1: Sample Statisics for 1D data: median, mean, mode, quartiles and quantiles.

Lecture 2: Presenting Results and Precision, Calculating Sample Statistics, Visualizing 1D data with histograms, Caclulating Sample Statistics with Categories, Visualizing Categorical 1D data with Boxplots and Violin Plots.

Lecture 3: Sample Statisics for 2D data: Sample Covariance, Sample Correlation.

Lecture 4: Plotting 2D data (scatter plot) and computing sample covariance/correlation

Unit 8 — Central Limit Theorem and Confidence Intervals

Lecture 1: Central Limit Theorem and Theory of Confidence Intervals

Lecture 2: Computing Confidence Intervals

Unit 9 — Linear Algebra in Python

Periscope for mac os. Lecture 1: Python Tips & Tricks

Lecture 2: Matrix Algebra (linalg), Solving Systems of Equations, Eigenvector/Eigenvalue, Matrix Rank

Lecture 3: Numerical Differentiation, Numerical Integration via Trapezoidal Rule, Numerical Integration in Scipy, Anonymous Functions (lambda)

Unit 10: — Hypothesis Testing

Lecture 1: Introduction to Hypothesis Testing, the zM and Student’s t-Test

Lecture 2: Non-Parametric Statistics, Reading a CSV file in Pandas, Wilcoxon Sum of Ranks, Wilcoxon Signed Rank, Poisson Test, Binomial Test

Unit 11 — Optimization

Lecture 1: Common mistakes with functions, Scope, Root Finding in 1D, Minimization in 1D, Convexity

Lecture 2: Root finding in multiple dimensions, Minimization in multiple dimensions, Bounded Optimization, Non-convex Optimization

Unit 12: — Regression

Lecture 1: Shapiro-Wilk Normality Test, Ordinary Least-Squares Linear Regression in 1- (OLS-1D) and N dimensions (OLS-ND), Standard error, Uncertainty in OLS-1D, OLS-ND, Fit coefficient hypothesis tests, Fit coefficient confidence intervals, Overview of steps to justify and perform regression (bottom of lecture)

Lecture 2: Non-linear regression and error analysis. Deconvoluting spectrum example.

Lecture 3: Regressing categorical data with discrete domains

Lecture 4: Regressing with constant uncertainty/measurement error in independent and/or dependent variables

Unit 13: — Differential Equations & Uncertainty Propagation

Lecture 1: Standard form and categorizing differential equations, Solving ODEs

Lecture 2: Error propagation through numerical derivatives, statistical fallacies

Unit 14: — Applied Python - Working with Data

Lecture 1: Dealing with duplicate, missing, NaN, non-contiguous, out of order data, Joining datasets, Using Pandas, Using Seaborn, Computing Running Means

Lecture 2: Packaging and deploying Python modules

Unit 15: — What to do now

Lecture 1: Next steps to learn more about numerical methods, statistics, and programming

Unit 16: — MATLAB

Lecture 1: An overview of MATLAB, the Jupyter Hub server and Excel

Unit 17: — User Interfaces

Lecture 1: Creating and writing animations

Lecture 2: Introduction to HTML, CSS, JS and modifying notebook style

Unit 18: — Design of Experiments

Lecture 1: Tables of experiments, vocabulary of design of experiments, ANOVA, factorial design, fractional factorial design, nuisance factors, blocking

Markdown Formatting

The five most important concepts to format your code appropriately when using markdown are:

  1. Italics: Surround your text with ‘_’ or ‘*’
  2. Bold: Surround your text with ‘__’ or ‘**’
  3. inline: Surround your text with ‘`’
  4. blockquote: Place ‘>’ before your text.

  5. Links: Surround the text you want to link with ‘[]’ and place the link adjacent to the text, surrounded with ‘()’

Headings

Notice that including a hashtag before the text in a markdown cell makes the text a heading. The number of hashtags you include will determine the priority of the header (‘#’ is level one, ‘##’ is level two, ‘###’ is level three and ‘####’ is level four).

H2

H3

H4

H5
H6

Alternatively, for H1 and H2, an underline-ish style:

Alt-H2

Emphasis

Emphasis, aka italics, with asterisks or underscores.

Strong emphasis, aka bold, with asterisks or underscores.

Combined emphasis with asterisks and underscores.

Strikethrough uses two tildes. Scratch this.

Notebook

Lists

There are three types of lists in markdown.

Ordered list:

  1. Step 1
    1. Step 1B
  2. Step 3

Unordered list

  • CESM-POP
  • CESM-MOM
  • CESM-CAM

Task list

  • Learn Jupyter Notebooks
    • Writing
    • Modes
    • Other Considerations
  • Submit Paper

NOTE:

Double click on each to see how they are built!

Images

Here’s our logo (hover to see the title text):

Inline-style:

R In Jupyter Notebook

Reference-style:

Code and Syntax Highlighting

Code blocks are part of the Markdown spec, but syntax highlighting isn’t. However, many renderers – like Github’s and Markdown Here – support syntax highlighting. Markdown Here supports highlighting for dozens of languages (and not-really-languages, like diffs and HTTP headers); to see the complete list, and how to write the language names, see the highlight.js demo page.

Horizontal rule in jupyter notebooks

Inline code has back-ticks around it.

Blocks of code are either fenced by lines with three back-ticks ```, or are indented with four spaces. I recommend only using the fenced code blocks – they’re easier and only they support syntax highlighting.

Again, to see what languages are available for highlighting, and how to write those language names, see the highlight.js demo page.

Tables

Tables aren’t part of the core Markdown spec, but they are part of GFM and Markdown Here supports them.

Colons can be used to align columns.

TablesAreCool
col 3 isright-aligned$1600
col 2 iscentered$12
zebra stripesare neat$1

Blockquotes

Blockquotes are very handy in email to emulate reply text.This line is part of the same quote.

Quote break.

This is a very long line that will still be quoted properly when it wraps. Oh boy let’s keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can putMarkdown into a blockquote.

Inline HTML

You can also use raw HTML in your Markdown, and it’ll mostly work pretty well.

Definition list
Is something people use sometimes.
Markdown in HTML
Does *not* work **very** well. Use HTML tags.
Notebook

Horizontal Rule

Three or more…

Hyphens

Asterisks

Underscores

Line Breaks

My basic recommendation for learning how line breaks work is to experiment and discover – hit <Enter> once (i.e., insert one newline), then hit it twice (i.e., insert two newlines), see what happens. You’ll soon learn to get what you want. “Markdown Toggle” is your friend.

Here are some things to try out:

Here’s a line for us to start with.

This line is separated from the one above by two newlines, so it will be a separate paragraph. Seagate freeagent for mac driver.

This line is also begins a separate paragraph, but…This line is only separated by a single newline, so it’s a separate line in the same paragraph.

(Technical note: Markdown Here uses GFM line breaks, so there’s no need to use MD’s two-space line breaks.)

YouTube Videos

They can’t be added directly but you can add an image with a link to the video like this:

Or, in pure Markdown, but losing the image sizing and border:

TeX Mathematical Formulae

A full description of TeX math symbols is beyond the scope of this cheatsheet. Here’s a good reference, and you can try stuff out on CodeCogs. You can also play with formulae in the Markdown Here options page.

Here are some examples to try out:

The beginning and ending dollar signs ($) are the delimiters for the TeX markup.

Rendered Tex:

$-b pm sqrt{b^2 - 4ac} over 2a$$x = a_0 + frac{1}{a_1 + frac{1}{a_2 + frac{1}{a_3 + a_4}}}$$forall x in X, quad exists y leq epsilon$

Code Capabilities

Code cells are different than Markdown cells in that they have an output cell. This means that we can keep the results of our code within the notebook and share them. Let’s say we want to show a graph that explains the result of an experiment. We can just run the necessary cells and save the notebook. The output will be there when we open it again! Try it out by running the next four cells.

We can also print images while experimenting.

  • Even videos:

Why Use Jupyter Notebook

Shortcuts and tricks

Command Mode Shortcuts

There are a couple of useful keyboard shortcuts in Command Mode that you can leverage to make Jupyter Notebook faster to use. Remember that to switch back and forth between Command Mode and Edit Mode with Esc and Enter.

m: Convert cell to Markdown

y: Convert cell to Code

D+D: Delete cell

o: Toggle between hide or show output

Shift+Arrow up/Arrow down: Selects multiple cells. Once you have selected them you can operate on them like a batch (run, copy, paste etc).

Shift+M: Merge selected cells.

Shift+Tab: [press once] Tells you which parameters to pass on a function

Star In Jupyter Notebook

Shift+Tab: [press three times] Gives additional information on the method

Cell Tricks

  • There are also some tricks that you can code into a cell.

?function-name: Shows the definition and docstring for that function

Horizontal

??function-name: Shows the source code for that function

Line Magics

Download music free for mac. Line magics are functions that you can run on cells and take as an argument the rest of the line from where they are called. You call them by placing a ‘%’ sign before the command. The most useful ones are:

%matplotlib inline: This command ensures that all matplotlib plots will be plotted in the output cell within the notebook and will be kept in the notebook when saved.

Horizontal Rule In Jupyter Notebook

%reload_ext autoreload, %autoreload 2: Reload all modules before executing a new line. If a module is edited, it is not necessary to rerun the import commands, the modules will be reloaded automatically.

These three commands can be called together at the beginning of every notebook.

Creating A Jupyter Notebook

%timeit: Runs a line multiple times and displays the average time it took to run it.

Jupyter Notebook Windows

%debug: Allows to inspect a function which is showing an error using the Python debugger.