<jupyter_start><jupyter_text>Stochastic Processes: Data Analysis and Computer Simulation  Python programming for beginners   -Using Python, iPython, and Jupyter notebook-  Note 1- In this course, we will use the Jupyter notebook as our programming environment. - It is freely available for Windows, Mac, and Linux through the Anaconda Python Distribution. - In this plot, I will explain how to install and use the Jupyter notebook in a step-by-step manner to create some common visualizations that we will use throughout this course.  Install anaconda  Instractions- Download the Python 3.$*$ Anaconda package appropriate for your platform (Windows/Mac/Linux) from the official website (https://www.continuum.io/downloads). - Install anaconda by executing the installer program (see details at https://docs.continuum.io/anaconda/install).- You can update to the latest version of Anaconda by executing the following commands from the command line (optional). ```conda update condaconda update anaconda```  Note 2- Let us now install Anaconda. - First, visit the download page of the official Anaconda website and download the latest version of the Python-3 Anaconda package appropriate for your platform, Windows, Mac, or Linux. - Here, we will be working with the 64-bit Anaconda 4.3.0 distribution for Mac OSX with Python 3.6, but other combinations should also work.- Second, run the installer program (".exe" executable file on Windows, ".dmg" disk image file on Mac, or ".sh" shell script on Linux) and follow the instructions shown on the screen.- The installer may ask some questions during the procedure. - If you are not sure how to answer, accepting the default responses should be fine.- You can update to the latest Anaconda version by executing the commands shown here from the command prompt, but this is only optional.  Launch jupyter notebook  Note 3- To launch the Jupyter notebook, first, open the "Terminal" application on Mac or Linux, or the "Command Prompt" on Windows to use the command line. - It is probably convenient if you create a new folder or directory to store the notebooks for this course. - Now, change into your chosen directory using the command shown here.- Then, you can launch the Jupiter notebook by typing "`jupyter notebook`" in the command line. - Some information will be displayed on your screen, which you can ignore; then the Jupyter notebook will be opened in your web-browser with a local URL (by default, http://localhost:8888).- Here we use the Safari web-browser on Mac, but you should observe the same results under other operating systems or browsers.  Demonstration```mkdir workcd work   jupyter notebook[I 18:10:21.427 NotebookApp] Serving notebooks from local directory: /Users/ryoichi/work[I 18:10:21.427 NotebookApp] 0 active kernels ...```![](fig/01.png)  Note 4- Next, we will start a new Python kernel. - Click on the "New" icon, and select "Python 3" which is circled in red in the following figure. - The Jupyter notebook works with many different programming languages (or kernels), not just Python, but we will not be using this capability for this course. - If you can see more than two "Python" options in the "New" menu, please be sure to choose Python version 3.- Here we just choose "Python 3".  Demo continued...![](fig/02a.png)  Note 5- Then a new notebook will open, with an empty box or "Cell", in which you can type and run python commands interactively.   Demo continued...![](fig/03.png)  Check Python version  Note 6- To be sure that you are running a proper Python3 version, type the following commands in the cell and run it by performing one of the following operations. - The system will print the version number of the Python interpreter you are currently using. - If it is found to be 2.$*$.$*$, please uninstall the present Anaconda and re-install another Anaconda with a proper version of 3.$*$.$*$.  Demonstration- Type the following commands, and perform one of the followings or click the icon circled in red in the figure. 1. press "Control-Return" 1. choose "Cell" menu -> "Insert Cell below".<jupyter_code>import sys
sys.version<jupyter_output><empty_output><jupyter_text>![](fig/03b.png)  Use jupyter notebook to run Python in interactive mode: Code mode  Creat a new sell  Note 7- Here, let us use cells in code mode to run Python in interactive mode. - First, perform one of the following operations to create a new cell.  Instructions- Perform one of the following operations to create a new cell.  1. press "Shift-Return" 1. choose "Insert" -> "Insert Cell below" from the menubar. 1. click "+" icon circled in blue in the figure.  ![](fig/03c.png)  The simplest calculation  A code example<jupyter_code>1+1<jupyter_output><empty_output><jupyter_text>Note 8- Type "1+1" in the new cell and run it. - Then you will find the answer "2" as an output. - The cell is editable by clicking on it.  Mathematical functions A code example<jupyter_code>import numpy as np
thrad=0.5
theta=thrad*np.pi
sinth=np.sin(theta)
costh=np.cos(theta)
print('theta =',thrad,'* pi')
print('sin(theta) =',sinth)
print('cos(theta) =',costh)<jupyter_output>theta = 0.5 * pi
sin(theta) = 1.0
cos(theta) = 6.12323399574e-17
{'fraction_non_alphanumeric': 0.07413826304640862, 'fraction_numerical': 0.016560754862314654, 'mean_word_length': 4.416058394160584, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 14, 'https://': 2, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '500918', 'license': 'MIT', 'n_tokens_mistral': 1466, 'n_tokens_neox': 1368, 'n_words': 756, 'path': 'edx-stochastic-data-analysis/downloaded_files/01/.ipynb_checkpoints/Stochastic_Processes_week01_1-checkpoint.ipynb', 'repo_name': 'mirandagil/extra-courses', 'size': '5193'}