Are you over 18 and want to see adult content?
More Annotations
A complete backup of drinkwise.org.au
Are you over 18 and want to see adult content?
A complete backup of www.michaelkorshandbagsuk.uk
Are you over 18 and want to see adult content?
A complete backup of calawyersforthearts.org
Are you over 18 and want to see adult content?
A complete backup of gradient-animator.com
Are you over 18 and want to see adult content?
A complete backup of philosophy-index.com
Are you over 18 and want to see adult content?
Favourite Annotations
A complete backup of cialissansordonnancefr.com
Are you over 18 and want to see adult content?
A complete backup of goodlookingloser.com
Are you over 18 and want to see adult content?
A complete backup of grillinfools.com
Are you over 18 and want to see adult content?
A complete backup of bridgerestauranthp.com
Are you over 18 and want to see adult content?
A complete backup of anthropology.net
Are you over 18 and want to see adult content?
Text
MAKING A MAZE
Posted by: christian on 13 Apr 2017 (13 comments) The Depth-first search algorithm is a simple approach to generating a maze. It is well described and illustrated in lots of places on the internet, so only an outline is given here.. The maze is considered to consist of a grid of cells; each cell initially has four walls (North, East, South andWest).
A VERY SIMPLE 2-D DIFFUSION MODEL A very simple 2-D diffusion model. A very simple diffusion simulation can be constructed in two dimensions by following the positions of a number of "particles" which all start off at the centre of a grid of cells. Time is assumed to progress in a series of "ticks": at each tick, each particle's position changes at random by − 1, 0, or + 1 PLOTTING THE DECISION BOUNDARY OF A LOGISTIC REGRESSION MODEL Plotting the decision boundary of a logistic regression model. In the notation of this previous post, a logistic regression binary classification model takes an input feature vector, x, and returns a probability, y ^, that x belongs to a particular class: y ^ = P ( y = 1 | x). The model is trained on a set of provided example featurevectors, x
THE SIR EPIDEMIC MODEL The SIR epidemic model. A simple mathematical description of the spread of a disease in a population is the so-called SIR model, which divides the (fixed) population of N individuals into three "compartments" which may vary as a function of time, t: R ( t) are those individuals who have recovered from the disease and now haveimmunity to it.
THE BOUNDING BOX OF A ROTATED OBJECT The following code plots a two-dimensional object and its bounding box for several rotations about an arbitrary point. Three types of bounding box are considered: (1) the original bounding box, rotated by the same amount as the object, (2) the bounding box to that bounding box (such that its sides remain parallel to the axes), and (3) the bounding box to the rotated object with sides parallel INSET PLOTS IN MATPLOTLIB The files used in this code are: Ta-Cp.txt, Ta-CV_Einstein.txt, Ta-CV_Debye.txt. The key lines of this program are those creating a second set of Axes, ax2 and attaching them in an inset position to the figure. The list of values set the lower left position of the Axes (x, y coordinates) and its width and height respectively in fractional units of the dimensions of the THE MATRIX TRANSPOSE BY LIST COMPREHENSION The matrix transpose by list comprehension. Consider a 3 × 3 matrix represented by a list of lists: M = Without using list comprehension, the transpose of this matrix could be built up by looping over the rows and columns: MT = for NUCLEAR BINDING ENERGIES #2 Nuclear binding energies #2. ( 0 comments ) The semi-empirical mass formula parameters used in the previous post were taken from the text book of J. W. Rohlf (1994) . Another, older set of parameters are presented in the compilation of A. H. Wapstra (1958) . Below we compare each with the experimental data from the OECD-NEA (in the file THE TWO-DIMENSIONAL SINC FUNCTION Question Q7.2.1. Generate an image plot of the sinc function in the Cartesian plane, s i n c ( r) = sin. . r / r where r = x 2 + y 2. LEARNING SCIENTIFIC PROGRAMMING WITH PYTHONABOUTBOOKBLOGAPPSCONTACTCHAPTER 1: INTRODUCTION A shallow neural network for simple nonlinear classification. Plotting the decision boundary of a logistic regression model. Logistic regression for image classification. The Maxwell–Boltzmann distribution in two dimensions. Visualizing the real forms of the spherical harmonics. The Babylonian spiral.MAKING A MAZE
Posted by: christian on 13 Apr 2017 (13 comments) The Depth-first search algorithm is a simple approach to generating a maze. It is well described and illustrated in lots of places on the internet, so only an outline is given here.. The maze is considered to consist of a grid of cells; each cell initially has four walls (North, East, South andWest).
A VERY SIMPLE 2-D DIFFUSION MODEL A very simple 2-D diffusion model. A very simple diffusion simulation can be constructed in two dimensions by following the positions of a number of "particles" which all start off at the centre of a grid of cells. Time is assumed to progress in a series of "ticks": at each tick, each particle's position changes at random by − 1, 0, or + 1 PLOTTING THE DECISION BOUNDARY OF A LOGISTIC REGRESSION MODEL Plotting the decision boundary of a logistic regression model. In the notation of this previous post, a logistic regression binary classification model takes an input feature vector, x, and returns a probability, y ^, that x belongs to a particular class: y ^ = P ( y = 1 | x). The model is trained on a set of provided example featurevectors, x
THE SIR EPIDEMIC MODEL The SIR epidemic model. A simple mathematical description of the spread of a disease in a population is the so-called SIR model, which divides the (fixed) population of N individuals into three "compartments" which may vary as a function of time, t: R ( t) are those individuals who have recovered from the disease and now haveimmunity to it.
THE BOUNDING BOX OF A ROTATED OBJECT The following code plots a two-dimensional object and its bounding box for several rotations about an arbitrary point. Three types of bounding box are considered: (1) the original bounding box, rotated by the same amount as the object, (2) the bounding box to that bounding box (such that its sides remain parallel to the axes), and (3) the bounding box to the rotated object with sides parallel INSET PLOTS IN MATPLOTLIB The files used in this code are: Ta-Cp.txt, Ta-CV_Einstein.txt, Ta-CV_Debye.txt. The key lines of this program are those creating a second set of Axes, ax2 and attaching them in an inset position to the figure. The list of values set the lower left position of the Axes (x, y coordinates) and its width and height respectively in fractional units of the dimensions of the THE MATRIX TRANSPOSE BY LIST COMPREHENSION The matrix transpose by list comprehension. Consider a 3 × 3 matrix represented by a list of lists: M = Without using list comprehension, the transpose of this matrix could be built up by looping over the rows and columns: MT = for NUCLEAR BINDING ENERGIES #2 Nuclear binding energies #2. ( 0 comments ) The semi-empirical mass formula parameters used in the previous post were taken from the text book of J. W. Rohlf (1994) . Another, older set of parameters are presented in the compilation of A. H. Wapstra (1958) . Below we compare each with the experimental data from the OECD-NEA (in the file THE TWO-DIMENSIONAL SINC FUNCTION Question Q7.2.1. Generate an image plot of the sinc function in the Cartesian plane, s i n c ( r) = sin. . r / r where r = x 2 + y 2.THE SPRING PENDULUM
The spring is assumed to have a force constant k and an equilibrium length l 0 such that its potential energy when extended or compressed to a length l is 1 2 k ( l − l 0) 2. The components of the bob's position and velocity are: x = l sin. . θ x ˙ = l ˙ sin. . θ + l θ ˙ cos. . θ y = − l cos. INSET PLOTS IN MATPLOTLIB The files used in this code are: Ta-Cp.txt, Ta-CV_Einstein.txt, Ta-CV_Debye.txt. The key lines of this program are those creating a second set of Axes, ax2 and attaching them in an inset position to the figure. The list of values set the lower left position of the Axes (x, y coordinates) and its width and height respectively in fractional units of the dimensions of the THE BOUNDING BOX OF A ROTATED OBJECT The following code plots a two-dimensional object and its bounding box for several rotations about an arbitrary point. Three types of bounding box are considered: (1) the original bounding box, rotated by the same amount as the object, (2) the bounding box to that bounding box (such that its sides remain parallel to the axes), and (3) the bounding box to the rotated object with sides parallel THE LORENZ ATTRACTOR The Lorenz attractor. The Lorenz system of coupled, ordinary, first-order differential equations have chaotic solutions for certain parameter values σ, ρ and β and initial conditions, u ( 0), v ( 0) and w ( 0). The following program plots the Lorenz attractor (the values of x, y and z as a parametric function of time) on a Matplotlib3D
THE DOUBLE COMPOUND PENDULUM Following on from this post about the simple double pendulum, (two bobs connected by light, rigid rods), this post animates the double compound pendulum (also called a double complex or physical pendulum): two rods connected to each other, with their mass distributed along their length. The analysis on Wikipedia provides the dynamical equations for the case of equal-mass and equal-length PLOTTING COVID-19 CASES Plotting COVID-19 cases. The Centre for Systems Science and Engineering (CSSE) at Johns Hopkins University publishes daily statistics of the number of confirmed cases of COVID-19 by country on its GitHub page. The short script below pulls data from this page to plot a bar chart of cases and growth in cases as a function of time for a given country. TWO-DIMENSIONAL COLLISIONS This small Python project is a physical simulation of two-dimensional physics. The animation is carried out using Matplotlib's FuncAnimation method and is implemented by the class Simulation. Each "particle" of the simulation is represented by an instance of the Particle class and depicted as a circle with a fixed radius which undergoes elastic collisions with other particles. NUCLEAR BINDING ENERGIES #2 Nuclear binding energies #2. ( 0 comments ) The semi-empirical mass formula parameters used in the previous post were taken from the text book of J. W. Rohlf (1994) . Another, older set of parameters are presented in the compilation of A. H. Wapstra (1958) . Below we compare each with the experimental data from the OECD-NEA (in the file THE TWO-DIMENSIONAL SINC FUNCTION Question Q7.2.1. Generate an image plot of the sinc function in the Cartesian plane, s i n c ( r) = sin. . r / r where r = x 2 + y 2. VISUALIZING A VECTOR FIELD WITH MATPLOTLIB Matplotlib provides a function, streamplot, to create a plot of streamlines representing a vector field. The following program displays a representation of the electric field vector resulting from a multipole arrangement of charges. The multipole is selected as a power of 2 on the command line (1=dipole, 2=quadrupole, etc.) LEARNING SCIENTIFIC PROGRAMMING WITH PYTHONABOUTBOOKBLOGAPPSCONTACTCHAPTER 1: INTRODUCTION A shallow neural network for simple nonlinear classification. Plotting the decision boundary of a logistic regression model. Logistic regression for image classification. The Maxwell–Boltzmann distribution in two dimensions. Visualizing the real forms of the spherical harmonics. The Babylonian spiral.MAKING A MAZE
Posted by: christian on 13 Apr 2017 (13 comments) The Depth-first search algorithm is a simple approach to generating a maze. It is well described and illustrated in lots of places on the internet, so only an outline is given here.. The maze is considered to consist of a grid of cells; each cell initially has four walls (North, East, South andWest).
A VERY SIMPLE 2-D DIFFUSION MODEL A very simple 2-D diffusion model. A very simple diffusion simulation can be constructed in two dimensions by following the positions of a number of "particles" which all start off at the centre of a grid of cells. Time is assumed to progress in a series of "ticks": at each tick, each particle's position changes at random by − 1, 0, or + 1 PLOTTING THE DECISION BOUNDARY OF A LOGISTIC REGRESSION MODEL Plotting the decision boundary of a logistic regression model. In the notation of this previous post, a logistic regression binary classification model takes an input feature vector, x, and returns a probability, y ^, that x belongs to a particular class: y ^ = P ( y = 1 | x). The model is trained on a set of provided example featurevectors, x
THE SIR EPIDEMIC MODEL The SIR epidemic model. A simple mathematical description of the spread of a disease in a population is the so-called SIR model, which divides the (fixed) population of N individuals into three "compartments" which may vary as a function of time, t: R ( t) are those individuals who have recovered from the disease and now haveimmunity to it.
THE BOUNDING BOX OF A ROTATED OBJECT The following code plots a two-dimensional object and its bounding box for several rotations about an arbitrary point. Three types of bounding box are considered: (1) the original bounding box, rotated by the same amount as the object, (2) the bounding box to that bounding box (such that its sides remain parallel to the axes), and (3) the bounding box to the rotated object with sides parallel INSET PLOTS IN MATPLOTLIB The files used in this code are: Ta-Cp.txt, Ta-CV_Einstein.txt, Ta-CV_Debye.txt. The key lines of this program are those creating a second set of Axes, ax2 and attaching them in an inset position to the figure. The list of values set the lower left position of the Axes (x, y coordinates) and its width and height respectively in fractional units of the dimensions of the THE MATRIX TRANSPOSE BY LIST COMPREHENSION The matrix transpose by list comprehension. Consider a 3 × 3 matrix represented by a list of lists: M = Without using list comprehension, the transpose of this matrix could be built up by looping over the rows and columns: MT = for NUCLEAR BINDING ENERGIES #2 Nuclear binding energies #2. ( 0 comments ) The semi-empirical mass formula parameters used in the previous post were taken from the text book of J. W. Rohlf (1994) . Another, older set of parameters are presented in the compilation of A. H. Wapstra (1958) . Below we compare each with the experimental data from the OECD-NEA (in the file THE TWO-DIMENSIONAL SINC FUNCTION Question Q7.2.1. Generate an image plot of the sinc function in the Cartesian plane, s i n c ( r) = sin. . r / r where r = x 2 + y 2. LEARNING SCIENTIFIC PROGRAMMING WITH PYTHONABOUTBOOKBLOGAPPSCONTACTCHAPTER 1: INTRODUCTION A shallow neural network for simple nonlinear classification. Plotting the decision boundary of a logistic regression model. Logistic regression for image classification. The Maxwell–Boltzmann distribution in two dimensions. Visualizing the real forms of the spherical harmonics. The Babylonian spiral.MAKING A MAZE
Posted by: christian on 13 Apr 2017 (13 comments) The Depth-first search algorithm is a simple approach to generating a maze. It is well described and illustrated in lots of places on the internet, so only an outline is given here.. The maze is considered to consist of a grid of cells; each cell initially has four walls (North, East, South andWest).
A VERY SIMPLE 2-D DIFFUSION MODEL A very simple 2-D diffusion model. A very simple diffusion simulation can be constructed in two dimensions by following the positions of a number of "particles" which all start off at the centre of a grid of cells. Time is assumed to progress in a series of "ticks": at each tick, each particle's position changes at random by − 1, 0, or + 1 PLOTTING THE DECISION BOUNDARY OF A LOGISTIC REGRESSION MODEL Plotting the decision boundary of a logistic regression model. In the notation of this previous post, a logistic regression binary classification model takes an input feature vector, x, and returns a probability, y ^, that x belongs to a particular class: y ^ = P ( y = 1 | x). The model is trained on a set of provided example featurevectors, x
THE SIR EPIDEMIC MODEL The SIR epidemic model. A simple mathematical description of the spread of a disease in a population is the so-called SIR model, which divides the (fixed) population of N individuals into three "compartments" which may vary as a function of time, t: R ( t) are those individuals who have recovered from the disease and now haveimmunity to it.
THE BOUNDING BOX OF A ROTATED OBJECT The following code plots a two-dimensional object and its bounding box for several rotations about an arbitrary point. Three types of bounding box are considered: (1) the original bounding box, rotated by the same amount as the object, (2) the bounding box to that bounding box (such that its sides remain parallel to the axes), and (3) the bounding box to the rotated object with sides parallel INSET PLOTS IN MATPLOTLIB The files used in this code are: Ta-Cp.txt, Ta-CV_Einstein.txt, Ta-CV_Debye.txt. The key lines of this program are those creating a second set of Axes, ax2 and attaching them in an inset position to the figure. The list of values set the lower left position of the Axes (x, y coordinates) and its width and height respectively in fractional units of the dimensions of the THE MATRIX TRANSPOSE BY LIST COMPREHENSION The matrix transpose by list comprehension. Consider a 3 × 3 matrix represented by a list of lists: M = Without using list comprehension, the transpose of this matrix could be built up by looping over the rows and columns: MT = for NUCLEAR BINDING ENERGIES #2 Nuclear binding energies #2. ( 0 comments ) The semi-empirical mass formula parameters used in the previous post were taken from the text book of J. W. Rohlf (1994) . Another, older set of parameters are presented in the compilation of A. H. Wapstra (1958) . Below we compare each with the experimental data from the OECD-NEA (in the file THE TWO-DIMENSIONAL SINC FUNCTION Question Q7.2.1. Generate an image plot of the sinc function in the Cartesian plane, s i n c ( r) = sin. . r / r where r = x 2 + y 2.THE SPRING PENDULUM
The spring is assumed to have a force constant k and an equilibrium length l 0 such that its potential energy when extended or compressed to a length l is 1 2 k ( l − l 0) 2. The components of the bob's position and velocity are: x = l sin. . θ x ˙ = l ˙ sin. . θ + l θ ˙ cos. . θ y = − l cos. INSET PLOTS IN MATPLOTLIB The files used in this code are: Ta-Cp.txt, Ta-CV_Einstein.txt, Ta-CV_Debye.txt. The key lines of this program are those creating a second set of Axes, ax2 and attaching them in an inset position to the figure. The list of values set the lower left position of the Axes (x, y coordinates) and its width and height respectively in fractional units of the dimensions of the THE BOUNDING BOX OF A ROTATED OBJECT The following code plots a two-dimensional object and its bounding box for several rotations about an arbitrary point. Three types of bounding box are considered: (1) the original bounding box, rotated by the same amount as the object, (2) the bounding box to that bounding box (such that its sides remain parallel to the axes), and (3) the bounding box to the rotated object with sides parallel THE LORENZ ATTRACTOR The Lorenz attractor. The Lorenz system of coupled, ordinary, first-order differential equations have chaotic solutions for certain parameter values σ, ρ and β and initial conditions, u ( 0), v ( 0) and w ( 0). The following program plots the Lorenz attractor (the values of x, y and z as a parametric function of time) on a Matplotlib3D
THE DOUBLE COMPOUND PENDULUM Following on from this post about the simple double pendulum, (two bobs connected by light, rigid rods), this post animates the double compound pendulum (also called a double complex or physical pendulum): two rods connected to each other, with their mass distributed along their length. The analysis on Wikipedia provides the dynamical equations for the case of equal-mass and equal-length PLOTTING COVID-19 CASES Plotting COVID-19 cases. The Centre for Systems Science and Engineering (CSSE) at Johns Hopkins University publishes daily statistics of the number of confirmed cases of COVID-19 by country on its GitHub page. The short script below pulls data from this page to plot a bar chart of cases and growth in cases as a function of time for a given country. TWO-DIMENSIONAL COLLISIONS This small Python project is a physical simulation of two-dimensional physics. The animation is carried out using Matplotlib's FuncAnimation method and is implemented by the class Simulation. Each "particle" of the simulation is represented by an instance of the Particle class and depicted as a circle with a fixed radius which undergoes elastic collisions with other particles. THE TWO-DIMENSIONAL SINC FUNCTION Question Q7.2.1. Generate an image plot of the sinc function in the Cartesian plane, s i n c ( r) = sin. . r / r where r = x 2 + y 2. QUADTREES #2: IMPLEMENTATION IN PYTHON The following code implements a Quadtree in Python (see the previous blog post). There are three classes: Point represents a point in two-dimensional space, with an optional "payload" (data structure associating the Point with more information, for example the identity of an object). The Rect class represents a rectangle in two-dimensional space through its centre, width and height. VISUALIZING A VECTOR FIELD WITH MATPLOTLIB Matplotlib provides a function, streamplot, to create a plot of streamlines representing a vector field. The following program displays a representation of the electric field vector resulting from a multipole arrangement of charges. The multipole is selected as a power of 2 on the command line (1=dipole, 2=quadrupole, etc.) LEARNING SCIENTIFIC PROGRAMMING WITH PYTHONABOUTBOOKBLOGAPPSCONTACTCHAPTER 1: INTRODUCTION A shallow neural network for simple nonlinear classification. Plotting the decision boundary of a logistic regression model. Logistic regression for image classification. The Maxwell–Boltzmann distribution in two dimensions. Visualizing the real forms of the spherical harmonics. The Babylonian spiral. INSET PLOTS IN MATPLOTLIB The files used in this code are: Ta-Cp.txt, Ta-CV_Einstein.txt, Ta-CV_Debye.txt. The key lines of this program are those creating a second set of Axes, ax2 and attaching them in an inset position to the figure. The list of values set the lower left position of the Axes (x, y coordinates) and its width and height respectively in fractional units of the dimensions of the A VERY SIMPLE 2-D DIFFUSION MODEL A very simple 2-D diffusion model. A very simple diffusion simulation can be constructed in two dimensions by following the positions of a number of "particles" which all start off at the centre of a grid of cells. Time is assumed to progress in a series of "ticks": at each tick, each particle's position changes at random by − 1, 0, or + 1MAKING A MAZE
Posted by: christian on 13 Apr 2017 (13 comments) The Depth-first search algorithm is a simple approach to generating a maze. It is well described and illustrated in lots of places on the internet, so only an outline is given here.. The maze is considered to consist of a grid of cells; each cell initially has four walls (North, East, South andWest).
THE VOIGT PROFILE
The Voigt profile. The Voigt line profile occurs in the modelling and analysis of radiative transfer in the atmosphere. It is the convolution of a Gaussian profile, G ( x; σ) and a Lorentzian profile, L ( x; γ) : ( − x 2 2 σ 2) a n d L ( x; γ) = γ / π x 2 + γ 2. 2. In terms of frequency, ν, x = ν − ν 0 where ν 0 isthe line centre.
CREATING A MAGIC SQUARE Otherwise increment n; Step 4. Move diagonally up and right, wrapping to the first column or last row if the move leads outside the grid. If this cell is already filled, move vertically down one space instead; Step 5. Return to step 2. The following program creates and PLOTTING THE DECISION BOUNDARY OF A LOGISTIC REGRESSION MODEL Plotting the decision boundary of a logistic regression model. In the notation of this previous post, a logistic regression binary classification model takes an input feature vector, x, and returns a probability, y ^, that x belongs to a particular class: y ^ = P ( y = 1 | x). The model is trained on a set of provided example featurevectors, x
THE SIR EPIDEMIC MODEL The SIR epidemic model. A simple mathematical description of the spread of a disease in a population is the so-called SIR model, which divides the (fixed) population of N individuals into three "compartments" which may vary as a function of time, t: R ( t) are those individuals who have recovered from the disease and now haveimmunity to it.
THE MATRIX TRANSPOSE BY LIST COMPREHENSION The matrix transpose by list comprehension. Consider a 3 × 3 matrix represented by a list of lists: M = Without using list comprehension, the transpose of this matrix could be built up by looping over the rows and columns: MT = for TWO-DIMENSIONAL COLLISIONS This small Python project is a physical simulation of two-dimensional physics. The animation is carried out using Matplotlib's FuncAnimation method and is implemented by the class Simulation. Each "particle" of the simulation is represented by an instance of the Particle class and depicted as a circle with a fixed radius which undergoes elastic collisions with other particles. LEARNING SCIENTIFIC PROGRAMMING WITH PYTHONABOUTBOOKBLOGAPPSCONTACTCHAPTER 1: INTRODUCTION A shallow neural network for simple nonlinear classification. Plotting the decision boundary of a logistic regression model. Logistic regression for image classification. The Maxwell–Boltzmann distribution in two dimensions. Visualizing the real forms of the spherical harmonics. The Babylonian spiral. INSET PLOTS IN MATPLOTLIB The files used in this code are: Ta-Cp.txt, Ta-CV_Einstein.txt, Ta-CV_Debye.txt. The key lines of this program are those creating a second set of Axes, ax2 and attaching them in an inset position to the figure. The list of values set the lower left position of the Axes (x, y coordinates) and its width and height respectively in fractional units of the dimensions of the A VERY SIMPLE 2-D DIFFUSION MODEL A very simple 2-D diffusion model. A very simple diffusion simulation can be constructed in two dimensions by following the positions of a number of "particles" which all start off at the centre of a grid of cells. Time is assumed to progress in a series of "ticks": at each tick, each particle's position changes at random by − 1, 0, or + 1MAKING A MAZE
Posted by: christian on 13 Apr 2017 (13 comments) The Depth-first search algorithm is a simple approach to generating a maze. It is well described and illustrated in lots of places on the internet, so only an outline is given here.. The maze is considered to consist of a grid of cells; each cell initially has four walls (North, East, South andWest).
THE VOIGT PROFILE
The Voigt profile. The Voigt line profile occurs in the modelling and analysis of radiative transfer in the atmosphere. It is the convolution of a Gaussian profile, G ( x; σ) and a Lorentzian profile, L ( x; γ) : ( − x 2 2 σ 2) a n d L ( x; γ) = γ / π x 2 + γ 2. 2. In terms of frequency, ν, x = ν − ν 0 where ν 0 isthe line centre.
CREATING A MAGIC SQUARE Otherwise increment n; Step 4. Move diagonally up and right, wrapping to the first column or last row if the move leads outside the grid. If this cell is already filled, move vertically down one space instead; Step 5. Return to step 2. The following program creates and PLOTTING THE DECISION BOUNDARY OF A LOGISTIC REGRESSION MODEL Plotting the decision boundary of a logistic regression model. In the notation of this previous post, a logistic regression binary classification model takes an input feature vector, x, and returns a probability, y ^, that x belongs to a particular class: y ^ = P ( y = 1 | x). The model is trained on a set of provided example featurevectors, x
THE SIR EPIDEMIC MODEL The SIR epidemic model. A simple mathematical description of the spread of a disease in a population is the so-called SIR model, which divides the (fixed) population of N individuals into three "compartments" which may vary as a function of time, t: R ( t) are those individuals who have recovered from the disease and now haveimmunity to it.
THE MATRIX TRANSPOSE BY LIST COMPREHENSION The matrix transpose by list comprehension. Consider a 3 × 3 matrix represented by a list of lists: M = Without using list comprehension, the transpose of this matrix could be built up by looping over the rows and columns: MT = for TWO-DIMENSIONAL COLLISIONS This small Python project is a physical simulation of two-dimensional physics. The animation is carried out using Matplotlib's FuncAnimation method and is implemented by the class Simulation. Each "particle" of the simulation is represented by an instance of the Particle class and depicted as a circle with a fixed radius which undergoes elastic collisions with other particles. A VERY SIMPLE 2-D DIFFUSION MODEL A very simple 2-D diffusion model. A very simple diffusion simulation can be constructed in two dimensions by following the positions of a number of "particles" which all start off at the centre of a grid of cells. Time is assumed to progress in a series of "ticks": at each tick, each particle's position changes at random by − 1, 0, or + 1MAKING A MAZE
Posted by: christian on 13 Apr 2017 (13 comments) The Depth-first search algorithm is a simple approach to generating a maze. It is well described and illustrated in lots of places on the internet, so only an outline is given here.. The maze is considered to consist of a grid of cells; each cell initially has four walls (North, East, South andWest).
THE MAXWELL CONSTRUCTION The Maxwell Construction. p c = a 27 b 2, V c = 3 b, k B T c = 8 a 27 b. Whilst the van der Waals equation does a better job than the ideal gas law of describing the properties of a real gas it suffers from an artefact for T r < 1 (that is, temperatures T < T c ), as shown in theplot below.
THE SIR EPIDEMIC MODEL The SIR epidemic model. A simple mathematical description of the spread of a disease in a population is the so-called SIR model, which divides the (fixed) population of N individuals into three "compartments" which may vary as a function of time, t: R ( t) are those individuals who have recovered from the disease and now haveimmunity to it.
THE BOUNDING BOX OF A ROTATED OBJECT The following code plots a two-dimensional object and its bounding box for several rotations about an arbitrary point. Three types of bounding box are considered: (1) the original bounding box, rotated by the same amount as the object, (2) the bounding box to that bounding box (such that its sides remain parallel to the axes), and (3) the bounding box to the rotated object with sides parallel SCIPY.INTERPOLATE.INTERP2D scipy.interpolate.interp2d. In the following example, we calculate the function. z ( x, y) = sin. . ( π x 2) e y / 2. on a grid of points ( x, y) which is not evenly-spaced in the y -direction. We then use scipy.interpolate.interp2d to interpolate these values onto a finer, evenly-spaced ( x, y) grid. THE TWO-DIMENSIONAL DIFFUSION EQUATION The two-dimensional diffusion equation. The two-dimensional diffusion equation is. ∂ U ∂ t = D ( ∂ 2 U ∂ x 2 + ∂ 2 U ∂ y 2) where D is the diffusion coefficient. A simple numerical solution on the domain of the unit square 0 ≤ x < 1, 0 ≤ y < 1 approximates U ( x, y; t) by the discrete function u i, THE HEIGHT OF LIQUID IN A SPHERICAL TANK Suppose a particular spherical tank has a radius R and is filled with a liquid to a height h. It is (fairly) easy to find a formula for the volume of liquid from the height: V = π R h 2 − 1 3 π h 3. Suppose that there is a constant flow of liquid from the tank at a rate F =− d V / d t.
A PROJECTILE WITH AIR RESISTANCE A projectile with air resistance. A spherical projectile of mass m launched with some initial velocity moves under the influence of two forces: gravity, F g = − m g z ^, and air resistance (drag), F D = − 1 2 c ρ A v 2 v / | v | = − 1 2 c ρ A v v, acting in the opposite direction to BINNING A 2D ARRAY IN NUMPY Binning a 2D array in NumPy. ( 6 comments ) The standard way to bin a large array to a smaller one by averaging is to reshape it into a higher dimension and then take the means over the appropriate new axes. The following function does this, assuming that each dimension of the new shape is a factor of the corresponding dimension in the oldone.
LEARNING SCIENTIFIC PROGRAMMING WITH PYTHONABOUTBOOKBLOGAPPSCONTACTCHAPTER 1: INTRODUCTION A shallow neural network for simple nonlinear classification. Plotting the decision boundary of a logistic regression model. Logistic regression for image classification. The Maxwell–Boltzmann distribution in two dimensions. Visualizing the real forms of the spherical harmonics. The Babylonian spiral. INSET PLOTS IN MATPLOTLIB The files used in this code are: Ta-Cp.txt, Ta-CV_Einstein.txt, Ta-CV_Debye.txt. The key lines of this program are those creating a second set of Axes, ax2 and attaching them in an inset position to the figure. The list of values set the lower left position of the Axes (x, y coordinates) and its width and height respectively in fractional units of the dimensions of the A VERY SIMPLE 2-D DIFFUSION MODEL A very simple 2-D diffusion model. A very simple diffusion simulation can be constructed in two dimensions by following the positions of a number of "particles" which all start off at the centre of a grid of cells. Time is assumed to progress in a series of "ticks": at each tick, each particle's position changes at random by − 1, 0, or + 1MAKING A MAZE
Posted by: christian on 13 Apr 2017 (13 comments) The Depth-first search algorithm is a simple approach to generating a maze. It is well described and illustrated in lots of places on the internet, so only an outline is given here.. The maze is considered to consist of a grid of cells; each cell initially has four walls (North, East, South andWest).
THE VOIGT PROFILE
The Voigt profile. The Voigt line profile occurs in the modelling and analysis of radiative transfer in the atmosphere. It is the convolution of a Gaussian profile, G ( x; σ) and a Lorentzian profile, L ( x; γ) : ( − x 2 2 σ 2) a n d L ( x; γ) = γ / π x 2 + γ 2. 2. In terms of frequency, ν, x = ν − ν 0 where ν 0 isthe line centre.
CREATING A MAGIC SQUARE Otherwise increment n; Step 4. Move diagonally up and right, wrapping to the first column or last row if the move leads outside the grid. If this cell is already filled, move vertically down one space instead; Step 5. Return to step 2. The following program creates and PLOTTING THE DECISION BOUNDARY OF A LOGISTIC REGRESSION MODEL Plotting the decision boundary of a logistic regression model. In the notation of this previous post, a logistic regression binary classification model takes an input feature vector, x, and returns a probability, y ^, that x belongs to a particular class: y ^ = P ( y = 1 | x). The model is trained on a set of provided example featurevectors, x
THE SIR EPIDEMIC MODEL The SIR epidemic model. A simple mathematical description of the spread of a disease in a population is the so-called SIR model, which divides the (fixed) population of N individuals into three "compartments" which may vary as a function of time, t: R ( t) are those individuals who have recovered from the disease and now haveimmunity to it.
THE MATRIX TRANSPOSE BY LIST COMPREHENSION The matrix transpose by list comprehension. Consider a 3 × 3 matrix represented by a list of lists: M = Without using list comprehension, the transpose of this matrix could be built up by looping over the rows and columns: MT = for TWO-DIMENSIONAL COLLISIONS This small Python project is a physical simulation of two-dimensional physics. The animation is carried out using Matplotlib's FuncAnimation method and is implemented by the class Simulation. Each "particle" of the simulation is represented by an instance of the Particle class and depicted as a circle with a fixed radius which undergoes elastic collisions with other particles. LEARNING SCIENTIFIC PROGRAMMING WITH PYTHONABOUTBOOKBLOGAPPSCONTACTCHAPTER 1: INTRODUCTION A shallow neural network for simple nonlinear classification. Plotting the decision boundary of a logistic regression model. Logistic regression for image classification. The Maxwell–Boltzmann distribution in two dimensions. Visualizing the real forms of the spherical harmonics. The Babylonian spiral. INSET PLOTS IN MATPLOTLIB The files used in this code are: Ta-Cp.txt, Ta-CV_Einstein.txt, Ta-CV_Debye.txt. The key lines of this program are those creating a second set of Axes, ax2 and attaching them in an inset position to the figure. The list of values set the lower left position of the Axes (x, y coordinates) and its width and height respectively in fractional units of the dimensions of the A VERY SIMPLE 2-D DIFFUSION MODEL A very simple 2-D diffusion model. A very simple diffusion simulation can be constructed in two dimensions by following the positions of a number of "particles" which all start off at the centre of a grid of cells. Time is assumed to progress in a series of "ticks": at each tick, each particle's position changes at random by − 1, 0, or + 1MAKING A MAZE
Posted by: christian on 13 Apr 2017 (13 comments) The Depth-first search algorithm is a simple approach to generating a maze. It is well described and illustrated in lots of places on the internet, so only an outline is given here.. The maze is considered to consist of a grid of cells; each cell initially has four walls (North, East, South andWest).
THE VOIGT PROFILE
The Voigt profile. The Voigt line profile occurs in the modelling and analysis of radiative transfer in the atmosphere. It is the convolution of a Gaussian profile, G ( x; σ) and a Lorentzian profile, L ( x; γ) : ( − x 2 2 σ 2) a n d L ( x; γ) = γ / π x 2 + γ 2. 2. In terms of frequency, ν, x = ν − ν 0 where ν 0 isthe line centre.
CREATING A MAGIC SQUARE Otherwise increment n; Step 4. Move diagonally up and right, wrapping to the first column or last row if the move leads outside the grid. If this cell is already filled, move vertically down one space instead; Step 5. Return to step 2. The following program creates and PLOTTING THE DECISION BOUNDARY OF A LOGISTIC REGRESSION MODEL Plotting the decision boundary of a logistic regression model. In the notation of this previous post, a logistic regression binary classification model takes an input feature vector, x, and returns a probability, y ^, that x belongs to a particular class: y ^ = P ( y = 1 | x). The model is trained on a set of provided example featurevectors, x
THE SIR EPIDEMIC MODEL The SIR epidemic model. A simple mathematical description of the spread of a disease in a population is the so-called SIR model, which divides the (fixed) population of N individuals into three "compartments" which may vary as a function of time, t: R ( t) are those individuals who have recovered from the disease and now haveimmunity to it.
THE MATRIX TRANSPOSE BY LIST COMPREHENSION The matrix transpose by list comprehension. Consider a 3 × 3 matrix represented by a list of lists: M = Without using list comprehension, the transpose of this matrix could be built up by looping over the rows and columns: MT = for TWO-DIMENSIONAL COLLISIONS This small Python project is a physical simulation of two-dimensional physics. The animation is carried out using Matplotlib's FuncAnimation method and is implemented by the class Simulation. Each "particle" of the simulation is represented by an instance of the Particle class and depicted as a circle with a fixed radius which undergoes elastic collisions with other particles. A VERY SIMPLE 2-D DIFFUSION MODEL A very simple 2-D diffusion model. A very simple diffusion simulation can be constructed in two dimensions by following the positions of a number of "particles" which all start off at the centre of a grid of cells. Time is assumed to progress in a series of "ticks": at each tick, each particle's position changes at random by − 1, 0, or + 1MAKING A MAZE
Posted by: christian on 13 Apr 2017 (13 comments) The Depth-first search algorithm is a simple approach to generating a maze. It is well described and illustrated in lots of places on the internet, so only an outline is given here.. The maze is considered to consist of a grid of cells; each cell initially has four walls (North, East, South andWest).
THE MAXWELL CONSTRUCTION The Maxwell Construction. p c = a 27 b 2, V c = 3 b, k B T c = 8 a 27 b. Whilst the van der Waals equation does a better job than the ideal gas law of describing the properties of a real gas it suffers from an artefact for T r < 1 (that is, temperatures T < T c ), as shown in theplot below.
THE SIR EPIDEMIC MODEL The SIR epidemic model. A simple mathematical description of the spread of a disease in a population is the so-called SIR model, which divides the (fixed) population of N individuals into three "compartments" which may vary as a function of time, t: R ( t) are those individuals who have recovered from the disease and now haveimmunity to it.
THE BOUNDING BOX OF A ROTATED OBJECT The following code plots a two-dimensional object and its bounding box for several rotations about an arbitrary point. Three types of bounding box are considered: (1) the original bounding box, rotated by the same amount as the object, (2) the bounding box to that bounding box (such that its sides remain parallel to the axes), and (3) the bounding box to the rotated object with sides parallel SCIPY.INTERPOLATE.INTERP2D scipy.interpolate.interp2d. In the following example, we calculate the function. z ( x, y) = sin. . ( π x 2) e y / 2. on a grid of points ( x, y) which is not evenly-spaced in the y -direction. We then use scipy.interpolate.interp2d to interpolate these values onto a finer, evenly-spaced ( x, y) grid. THE TWO-DIMENSIONAL DIFFUSION EQUATION The two-dimensional diffusion equation. The two-dimensional diffusion equation is. ∂ U ∂ t = D ( ∂ 2 U ∂ x 2 + ∂ 2 U ∂ y 2) where D is the diffusion coefficient. A simple numerical solution on the domain of the unit square 0 ≤ x < 1, 0 ≤ y < 1 approximates U ( x, y; t) by the discrete function u i, THE HEIGHT OF LIQUID IN A SPHERICAL TANK Suppose a particular spherical tank has a radius R and is filled with a liquid to a height h. It is (fairly) easy to find a formula for the volume of liquid from the height: V = π R h 2 − 1 3 π h 3. Suppose that there is a constant flow of liquid from the tank at a rate F =− d V / d t.
A PROJECTILE WITH AIR RESISTANCE A projectile with air resistance. A spherical projectile of mass m launched with some initial velocity moves under the influence of two forces: gravity, F g = − m g z ^, and air resistance (drag), F D = − 1 2 c ρ A v 2 v / | v | = − 1 2 c ρ A v v, acting in the opposite direction to BINNING A 2D ARRAY IN NUMPY Binning a 2D array in NumPy. ( 6 comments ) The standard way to bin a large array to a smaller one by averaging is to reshape it into a higher dimension and then take the means over the appropriate new axes. The following function does this, assuming that each dimension of the new shape is a factor of the corresponding dimension in the oldone.
LEARNING SCIENTIFIC PROGRAMMING WITH PYTHONABOUTBOOKBLOGAPPSCONTACTCHAPTER 1: INTRODUCTION Non-linear least squares fitting of a two-dimensional data. ExB drift for an arbitrary electric potential. Reaching OrbitMAKING A MAZE
Posted by: christian on 13 Apr 2017 (13 comments) The Depth-first search algorithm is a simple approach to generating a maze. It is well described and illustrated in lots of places on the internet, so only an outline is given here.. The maze is considered to consist of a grid of cells; each cell initially has four walls (North, East, South andWest).
PLOTTING THE DECISION BOUNDARY OF A LOGISTIC REGRESSION MODEL Posted by: christian on 17 Sep 2020 () In the notation of this previous post, a logistic regression binary classification model takes an input feature vector, $\boldsymbol{x}$, and returns a probability, $\hat{y}$, that $\boldsymbol{x}$ belongs to a particular class: $\hat{y} = P(y=1|\boldsymbol{x})$.The model is trained on a set of provided example feature vectors, A VERY SIMPLE 2-D DIFFUSION MODEL Posted by: christian on 21 May 2017 () A very simple diffusion simulation can be constructed in two dimensions by following the positions of a number of "particles" which all start off at the centreof a grid of cells.
THE BOUNDING BOX OF A ROTATED OBJECT The following code plots a two-dimensional object and its bounding box for several rotations about an arbitrary point. Three types of bounding box are considered: (1) the original bounding box, rotated by the same amount as the object, (2) the bounding box to that bounding box (such that its sides remain parallel to the axes), and (3) the bounding box to the rotated object with sides parallel INSET PLOTS IN MATPLOTLIB The files used in this code are: Ta-Cp.txt, Ta-CV_Einstein.txt, Ta-CV_Debye.txt. The key lines of this program are those creating a second set of Axes, ax2 and attaching them in an inset position to the figure. The list of values set the lower left position of the Axes (x, y coordinates) and its width and height respectively in fractional units of the dimensions of the NUCLEAR BINDING ENERGIES #2 The semi-empirical mass formula parameters used in the previous post were taken from the text book of J. W. Rohlf (1994) . Another, older set of parameters are presented in the compilation of A. H. Wapstra (1958). Below we compare each with the experimental datafrom the
THE LORENZ ATTRACTOR Boris 3 years, 7 months ago There is a discrepancy between the formula and the code for du/dt. Link | Reply THE MATRIX TRANSPOSE BY LIST COMPREHENSION Consider a $3\times 3$ matrix represented by a list of lists: Without using list comprehension, the transpose of this matrix could be built up by looping over the rows and columns: THE TWO-DIMENSIONAL SINC FUNCTION Generate an image plot of the sinc function in the Cartesian plane, $\mathrm{sinc}(r) = \sin r / r$ where $r = \sqrt{x^2+y^2}$. LEARNING SCIENTIFIC PROGRAMMING WITH PYTHONABOUTBOOKBLOGAPPSCONTACTCHAPTER 1: INTRODUCTION Non-linear least squares fitting of a two-dimensional data. ExB drift for an arbitrary electric potential. Reaching OrbitMAKING A MAZE
Posted by: christian on 13 Apr 2017 (13 comments) The Depth-first search algorithm is a simple approach to generating a maze. It is well described and illustrated in lots of places on the internet, so only an outline is given here.. The maze is considered to consist of a grid of cells; each cell initially has four walls (North, East, South andWest).
PLOTTING THE DECISION BOUNDARY OF A LOGISTIC REGRESSION MODEL Posted by: christian on 17 Sep 2020 () In the notation of this previous post, a logistic regression binary classification model takes an input feature vector, $\boldsymbol{x}$, and returns a probability, $\hat{y}$, that $\boldsymbol{x}$ belongs to a particular class: $\hat{y} = P(y=1|\boldsymbol{x})$.The model is trained on a set of provided example feature vectors, A VERY SIMPLE 2-D DIFFUSION MODEL Posted by: christian on 21 May 2017 () A very simple diffusion simulation can be constructed in two dimensions by following the positions of a number of "particles" which all start off at the centreof a grid of cells.
THE BOUNDING BOX OF A ROTATED OBJECT The following code plots a two-dimensional object and its bounding box for several rotations about an arbitrary point. Three types of bounding box are considered: (1) the original bounding box, rotated by the same amount as the object, (2) the bounding box to that bounding box (such that its sides remain parallel to the axes), and (3) the bounding box to the rotated object with sides parallel INSET PLOTS IN MATPLOTLIB The files used in this code are: Ta-Cp.txt, Ta-CV_Einstein.txt, Ta-CV_Debye.txt. The key lines of this program are those creating a second set of Axes, ax2 and attaching them in an inset position to the figure. The list of values set the lower left position of the Axes (x, y coordinates) and its width and height respectively in fractional units of the dimensions of the NUCLEAR BINDING ENERGIES #2 The semi-empirical mass formula parameters used in the previous post were taken from the text book of J. W. Rohlf (1994) . Another, older set of parameters are presented in the compilation of A. H. Wapstra (1958). Below we compare each with the experimental datafrom the
THE LORENZ ATTRACTOR Boris 3 years, 7 months ago There is a discrepancy between the formula and the code for du/dt. Link | Reply THE MATRIX TRANSPOSE BY LIST COMPREHENSION Consider a $3\times 3$ matrix represented by a list of lists: Without using list comprehension, the transpose of this matrix could be built up by looping over the rows and columns: THE TWO-DIMENSIONAL SINC FUNCTION Generate an image plot of the sinc function in the Cartesian plane, $\mathrm{sinc}(r) = \sin r / r$ where $r = \sqrt{x^2+y^2}$. THE LORENZ ATTRACTOR Boris 3 years, 7 months ago There is a discrepancy between the formula and the code for du/dt. Link | Reply INSET PLOTS IN MATPLOTLIB The files used in this code are: Ta-Cp.txt, Ta-CV_Einstein.txt, Ta-CV_Debye.txt. The key lines of this program are those creating a second set of Axes, ax2 and attaching them in an inset position to the figure. The list of values set the lower left position of the Axes (x, y coordinates) and its width and height respectively in fractional units of the dimensions of the THE SIR EPIDEMIC MODEL The plotted graph is shown below. Further Reading. M. J. Keeling and P. Rohani, Modeling Infectious Diseases in Humans and Animals, Princeton (2007). R. M. Anderson and R. M. May, Infectious Diseases of Humans: Dynamics and Control, OUP (1992).Infectious DiseasesTHE VOIGT PROFILE
The Voigt line profile occurs in the modelling and analysis of radiative transfer in the atmosphere. It is the convolution of a Gaussian profile, $G(x; \sigma)$ and a THE TWO-DIMENSIONAL DIFFUSION EQUATION To set a common colorbar for the four plots we define its own Axes, cbar_ax and make room for it with fig.subplots_adjust.The plots all use the same colour range, defined by vmin and vmax, so it doesn't matter which one we pass in the first argument to fig.colorbar.. The state of the system is plotted as an image at four different stages ofits evolution.
A 2D VECTOR CLASS
Although NumPy offers a faster option, it is still instructive to code a class for vectors in pure Python. The following code defines the Vector2D class and tests it for various operations. PLOTTING COVID-19 CASES The Centre for Systems Science and Engineering (CSSE) at Johns Hopkins University publishes daily statistics of the number of confirmed cases of COVID-19 by country on its GitHub page. The short script below pulls data from this page to plot a bar chart of cases and growth in cases as a function of time for a given country. For example: THE DOUBLE COMPOUND PENDULUM Following on from this post about the simple double pendulum, (two bobs connected by light, rigid rods), this post animates the double compound pendulum (also called a double complex or physical pendulum): two rods connected to each other, with their mass distributed along their length. The analysis on Wikipedia provides the dynamical equations for the case of equal-mass and equal-lengthTHE SPRING PENDULUM
Derivation of the equations of motion. There are two degrees of freedom in this problem, which are taken to be the angle of the pendulum from the vertical and the total length of the spring. VISUALIZING A VECTOR FIELD WITH MATPLOTLIB Matplotlib provides a function, streamplot, to create a plot of streamlines representing a vector field. The following program displays a representation of the electric field vector resulting from a multipole arrangement of charges. The multipole is selected as a power of 2 on the command line (1=dipole, 2=quadrupole, etc.) LEARNING SCIENTIFIC PROGRAMMING WITH PYTHONABOUTBOOKBLOGAPPSCONTACTCHAPTER 1: INTRODUCTION A shallow neural network for simple nonlinear classification. Plotting the decision boundary of a logistic regression model. Logistic regression for image classification. The Maxwell–Boltzmann distribution in two dimensions. Visualizing the real forms of the spherical harmonics. The Babylonian spiral.MAKING A MAZE
Posted by: christian on 13 Apr 2017 (13 comments) The Depth-first search algorithm is a simple approach to generating a maze. It is well described and illustrated in lots of places on the internet, so only an outline is given here.. The maze is considered to consist of a grid of cells; each cell initially has four walls (North, East, South andWest).
A VERY SIMPLE 2-D DIFFUSION MODEL A very simple 2-D diffusion model. A very simple diffusion simulation can be constructed in two dimensions by following the positions of a number of "particles" which all start off at the centre of a grid of cells. Time is assumed to progress in a series of "ticks": at each tick, each particle's position changes at random by − 1, 0, or + 1 INSET PLOTS IN MATPLOTLIB The files used in this code are: Ta-Cp.txt, Ta-CV_Einstein.txt, Ta-CV_Debye.txt. The key lines of this program are those creating a second set of Axes, ax2 and attaching them in an inset position to the figure. The list of values set the lower left position of the Axes (x, y coordinates) and its width and height respectively in fractional units of the dimensions of the THE BOUNDING BOX OF A ROTATED OBJECT The following code plots a two-dimensional object and its bounding box for several rotations about an arbitrary point. Three types of bounding box are considered: (1) the original bounding box, rotated by the same amount as the object, (2) the bounding box to that bounding box (such that its sides remain parallel to the axes), and (3) the bounding box to the rotated object with sides parallel THE LORENZ ATTRACTOR The Lorenz attractor. The Lorenz system of coupled, ordinary, first-order differential equations have chaotic solutions for certain parameter values σ, ρ and β and initial conditions, u ( 0), v ( 0) and w ( 0). The following program plots the Lorenz attractor (the values of x, y and z as a parametric function of time) on a Matplotlib3D
PLOTTING THE DECISION BOUNDARY OF A LOGISTIC REGRESSION MODEL Plotting the decision boundary of a logistic regression model. In the notation of this previous post, a logistic regression binary classification model takes an input feature vector, x, and returns a probability, y ^, that x belongs to a particular class: y ^ = P ( y = 1 | x). The model is trained on a set of provided example featurevectors, x
THE MATRIX TRANSPOSE BY LIST COMPREHENSION The matrix transpose by list comprehension. Consider a 3 × 3 matrix represented by a list of lists: M = Without using list comprehension, the transpose of this matrix could be built up by looping over the rows and columns: MT = for NUCLEAR BINDING ENERGIES #2 Nuclear binding energies #2. ( 0 comments ) The semi-empirical mass formula parameters used in the previous post were taken from the text book of J. W. Rohlf (1994) . Another, older set of parameters are presented in the compilation of A. H. Wapstra (1958) . Below we compare each with the experimental data from the OECD-NEA (in the file THE TWO-DIMENSIONAL SINC FUNCTION Question Q7.2.1. Generate an image plot of the sinc function in the Cartesian plane, s i n c ( r) = sin. . r / r where r = x 2 + y 2. LEARNING SCIENTIFIC PROGRAMMING WITH PYTHONABOUTBOOKBLOGAPPSCONTACTCHAPTER 1: INTRODUCTION A shallow neural network for simple nonlinear classification. Plotting the decision boundary of a logistic regression model. Logistic regression for image classification. The Maxwell–Boltzmann distribution in two dimensions. Visualizing the real forms of the spherical harmonics. The Babylonian spiral.MAKING A MAZE
Posted by: christian on 13 Apr 2017 (13 comments) The Depth-first search algorithm is a simple approach to generating a maze. It is well described and illustrated in lots of places on the internet, so only an outline is given here.. The maze is considered to consist of a grid of cells; each cell initially has four walls (North, East, South andWest).
A VERY SIMPLE 2-D DIFFUSION MODEL A very simple 2-D diffusion model. A very simple diffusion simulation can be constructed in two dimensions by following the positions of a number of "particles" which all start off at the centre of a grid of cells. Time is assumed to progress in a series of "ticks": at each tick, each particle's position changes at random by − 1, 0, or + 1 INSET PLOTS IN MATPLOTLIB The files used in this code are: Ta-Cp.txt, Ta-CV_Einstein.txt, Ta-CV_Debye.txt. The key lines of this program are those creating a second set of Axes, ax2 and attaching them in an inset position to the figure. The list of values set the lower left position of the Axes (x, y coordinates) and its width and height respectively in fractional units of the dimensions of the THE BOUNDING BOX OF A ROTATED OBJECT The following code plots a two-dimensional object and its bounding box for several rotations about an arbitrary point. Three types of bounding box are considered: (1) the original bounding box, rotated by the same amount as the object, (2) the bounding box to that bounding box (such that its sides remain parallel to the axes), and (3) the bounding box to the rotated object with sides parallel THE LORENZ ATTRACTOR The Lorenz attractor. The Lorenz system of coupled, ordinary, first-order differential equations have chaotic solutions for certain parameter values σ, ρ and β and initial conditions, u ( 0), v ( 0) and w ( 0). The following program plots the Lorenz attractor (the values of x, y and z as a parametric function of time) on a Matplotlib3D
PLOTTING THE DECISION BOUNDARY OF A LOGISTIC REGRESSION MODEL Plotting the decision boundary of a logistic regression model. In the notation of this previous post, a logistic regression binary classification model takes an input feature vector, x, and returns a probability, y ^, that x belongs to a particular class: y ^ = P ( y = 1 | x). The model is trained on a set of provided example featurevectors, x
THE MATRIX TRANSPOSE BY LIST COMPREHENSION The matrix transpose by list comprehension. Consider a 3 × 3 matrix represented by a list of lists: M = Without using list comprehension, the transpose of this matrix could be built up by looping over the rows and columns: MT = for NUCLEAR BINDING ENERGIES #2 Nuclear binding energies #2. ( 0 comments ) The semi-empirical mass formula parameters used in the previous post were taken from the text book of J. W. Rohlf (1994) . Another, older set of parameters are presented in the compilation of A. H. Wapstra (1958) . Below we compare each with the experimental data from the OECD-NEA (in the file THE TWO-DIMENSIONAL SINC FUNCTION Question Q7.2.1. Generate an image plot of the sinc function in the Cartesian plane, s i n c ( r) = sin. . r / r where r = x 2 + y 2. THE LORENZ ATTRACTOR The Lorenz attractor. The Lorenz system of coupled, ordinary, first-order differential equations have chaotic solutions for certain parameter values σ, ρ and β and initial conditions, u ( 0), v ( 0) and w ( 0). The following program plots the Lorenz attractor (the values of x, y and z as a parametric function of time) on a Matplotlib3D
THE SPRING PENDULUM
The spring is assumed to have a force constant k and an equilibrium length l 0 such that its potential energy when extended or compressed to a length l is 1 2 k ( l − l 0) 2. The components of the bob's position and velocity are: x = l sin. . θ x ˙ = l ˙ sin. . θ + l θ ˙ cos. . θ y = − l cos. SCIPY.INTERPOLATE.INTERP2D scipy.interpolate.interp2d. In the following example, we calculate the function. z ( x, y) = sin. . ( π x 2) e y / 2. on a grid of points ( x, y) which is not evenly-spaced in the y -direction. We then use scipy.interpolate.interp2d to interpolate these values onto a finer, evenly-spaced ( x, y) grid. THE SIR EPIDEMIC MODEL The SIR epidemic model. A simple mathematical description of the spread of a disease in a population is the so-called SIR model, which divides the (fixed) population of N individuals into three "compartments" which may vary as a function of time, t: R ( t) are those individuals who have recovered from the disease and now haveimmunity to it.
THE DOUBLE COMPOUND PENDULUM Following on from this post about the simple double pendulum, (two bobs connected by light, rigid rods), this post animates the double compound pendulum (also called a double complex or physical pendulum): two rods connected to each other, with their mass distributed along their length. The analysis on Wikipedia provides the dynamical equations for the case of equal-mass and equal-length rods. PLOTTING COVID-19 CASES Plotting COVID-19 cases. The Centre for Systems Science and Engineering (CSSE) at Johns Hopkins University publishes daily statistics of the number of confirmed cases of COVID-19 by country on its GitHub page. The short script below pulls data from this page to plot a bar chart of cases and growth in cases as a function of time for a given country.A 2D VECTOR CLASS
A 2D vector class. Although NumPy offers a faster option, it is still instructive to code a class for vectors in pure Python. The following code defines the Vector2D class and tests it for various operations. import math class Vector2D: """A two-dimensional vector with Cartesian coordinates.""" def __init__(self, x, y): self.x, self.y = x, y TWO-DIMENSIONAL COLLISIONS This small Python project is a physical simulation of two-dimensional physics. The animation is carried out using Matplotlib's FuncAnimation method and is implemented by the class Simulation. Each "particle" of the simulation is represented by an instance of the Particle class and depicted as a circle with a fixed radius which undergoes elastic collisions with other particles.THE MADHAVA SERIES
Use a for loop to estimate π from the first 20 terms of the Madhava series : π = 12 ( 1 − 1 3 ⋅ 3 + 1 5 ⋅ 3 2 − 1 7 ⋅ 3 3 +⋯).
VISUALIZING A VECTOR FIELD WITH MATPLOTLIB Matplotlib provides a function, streamplot, to create a plot of streamlines representing a vector field. The following program displays a representation of the electric field vector resulting from a multipole arrangement of charges. The multipole is selected as a power of 2 on the command line (1=dipole, 2=quadrupole, etc.) LEARNING SCIENTIFIC PROGRAMMING WITH PYTHONABOUTBOOKBLOGAPPSCONTACTCHAPTER 1: INTRODUCTIONINTRODUCTION TO PROGRAMMING WITH PYTHONLEARNING PYTHON PROGRAMMING PDF A shallow neural network for simple nonlinear classification. Plotting the decision boundary of a logistic regression model. Logistic regression for image classification. The Maxwell–Boltzmann distribution in two dimensions. Visualizing the real forms of the spherical harmonics. The Babylonian spiral.MAKING A MAZE
Posted by: christian on 13 Apr 2017 (13 comments) The Depth-first search algorithm is a simple approach to generating a maze. It is well described and illustrated in lots of places on the internet, so only an outline is given here.. The maze is considered to consist of a grid of cells; each cell initially has four walls (North, East, South andWest).
SCIPY.INTERPOLATE.INTERP2D scipy.interpolate.interp2d. In the following example, we calculate the function. z ( x, y) = sin. . ( π x 2) e y / 2. on a grid of points ( x, y) which is not evenly-spaced in the y -direction. We then use scipy.interpolate.interp2d to interpolate these values onto a finer, evenly-spaced ( x, y) grid. THE LORENZ ATTRACTOR The Lorenz attractor. The Lorenz system of coupled, ordinary, first-order differential equations have chaotic solutions for certain parameter values σ, ρ and β and initial conditions, u ( 0), v ( 0) and w ( 0). The following program plots the Lorenz attractor (the values of x, y and z as a parametric function of time) on a Matplotlib3D
THE SIR EPIDEMIC MODEL The SIR epidemic model. A simple mathematical description of the spread of a disease in a population is the so-called SIR model, which divides the (fixed) population of N individuals into three "compartments" which may vary as a function of time, t: R ( t) are those individuals who have recovered from the disease and now haveimmunity to it.
THE VOIGT PROFILE
The Voigt profile. The Voigt line profile occurs in the modelling and analysis of radiative transfer in the atmosphere. It is the convolution of a Gaussian profile, G ( x; σ) and a Lorentzian profile, L ( x; γ) : ( − x 2 2 σ 2) a n d L ( x; γ) = γ / π x 2 + γ 2. 2. In terms of frequency, ν, x = ν − ν 0 where ν 0 isthe line centre.
THE MATRIX TRANSPOSE BY LIST COMPREHENSION The matrix transpose by list comprehension. Consider a 3 × 3 matrix represented by a list of lists: M = Without using list comprehension, the transpose of this matrix could be built up by looping over the rows and columns: MT = for THE TWO-DIMENSIONAL SINC FUNCTION Question Q7.2.1. Generate an image plot of the sinc function in the Cartesian plane, s i n c ( r) = sin. . r / r where r = x 2 + y 2. VISUALIZING A VECTOR FIELD WITH MATPLOTLIB Matplotlib provides a function, streamplot, to create a plot of streamlines representing a vector field. The following program displays a representation of the electric field vector resulting from a multipole arrangement of charges. The multipole is selected as a power of 2 on the command line (1=dipole, 2=quadrupole, etc.) NUCLEAR BINDING ENERGIES #2 Nuclear binding energies #2. ( 0 comments ) The semi-empirical mass formula parameters used in the previous post were taken from the text book of J. W. Rohlf (1994) . Another, older set of parameters are presented in the compilation of A. H. Wapstra (1958) . Below we compare each with the experimental data from the OECD-NEA (in the file LEARNING SCIENTIFIC PROGRAMMING WITH PYTHONABOUTBOOKBLOGAPPSCONTACTCHAPTER 1: INTRODUCTIONINTRODUCTION TO PROGRAMMING WITH PYTHONLEARNING PYTHON PROGRAMMING PDF A shallow neural network for simple nonlinear classification. Plotting the decision boundary of a logistic regression model. Logistic regression for image classification. The Maxwell–Boltzmann distribution in two dimensions. Visualizing the real forms of the spherical harmonics. The Babylonian spiral.MAKING A MAZE
Posted by: christian on 13 Apr 2017 (13 comments) The Depth-first search algorithm is a simple approach to generating a maze. It is well described and illustrated in lots of places on the internet, so only an outline is given here.. The maze is considered to consist of a grid of cells; each cell initially has four walls (North, East, South andWest).
SCIPY.INTERPOLATE.INTERP2D scipy.interpolate.interp2d. In the following example, we calculate the function. z ( x, y) = sin. . ( π x 2) e y / 2. on a grid of points ( x, y) which is not evenly-spaced in the y -direction. We then use scipy.interpolate.interp2d to interpolate these values onto a finer, evenly-spaced ( x, y) grid. THE LORENZ ATTRACTOR The Lorenz attractor. The Lorenz system of coupled, ordinary, first-order differential equations have chaotic solutions for certain parameter values σ, ρ and β and initial conditions, u ( 0), v ( 0) and w ( 0). The following program plots the Lorenz attractor (the values of x, y and z as a parametric function of time) on a Matplotlib3D
THE SIR EPIDEMIC MODEL The SIR epidemic model. A simple mathematical description of the spread of a disease in a population is the so-called SIR model, which divides the (fixed) population of N individuals into three "compartments" which may vary as a function of time, t: R ( t) are those individuals who have recovered from the disease and now haveimmunity to it.
THE VOIGT PROFILE
The Voigt profile. The Voigt line profile occurs in the modelling and analysis of radiative transfer in the atmosphere. It is the convolution of a Gaussian profile, G ( x; σ) and a Lorentzian profile, L ( x; γ) : ( − x 2 2 σ 2) a n d L ( x; γ) = γ / π x 2 + γ 2. 2. In terms of frequency, ν, x = ν − ν 0 where ν 0 isthe line centre.
THE MATRIX TRANSPOSE BY LIST COMPREHENSION The matrix transpose by list comprehension. Consider a 3 × 3 matrix represented by a list of lists: M = Without using list comprehension, the transpose of this matrix could be built up by looping over the rows and columns: MT = for THE TWO-DIMENSIONAL SINC FUNCTION Question Q7.2.1. Generate an image plot of the sinc function in the Cartesian plane, s i n c ( r) = sin. . r / r where r = x 2 + y 2. VISUALIZING A VECTOR FIELD WITH MATPLOTLIB Matplotlib provides a function, streamplot, to create a plot of streamlines representing a vector field. The following program displays a representation of the electric field vector resulting from a multipole arrangement of charges. The multipole is selected as a power of 2 on the command line (1=dipole, 2=quadrupole, etc.) NUCLEAR BINDING ENERGIES #2 Nuclear binding energies #2. ( 0 comments ) The semi-empirical mass formula parameters used in the previous post were taken from the text book of J. W. Rohlf (1994) . Another, older set of parameters are presented in the compilation of A. H. Wapstra (1958) . Below we compare each with the experimental data from the OECD-NEA (in the file THE LORENZ ATTRACTOR The Lorenz attractor. The Lorenz system of coupled, ordinary, first-order differential equations have chaotic solutions for certain parameter values σ, ρ and β and initial conditions, u ( 0), v ( 0) and w ( 0). The following program plots the Lorenz attractor (the values of x, y and z as a parametric function of time) on a Matplotlib3D
THE BOUNDING BOX OF A ROTATED OBJECT The following code plots a two-dimensional object and its bounding box for several rotations about an arbitrary point. Three types of bounding box are considered: (1) the original bounding box, rotated by the same amount as the object, (2) the bounding box to that bounding box (such that its sides remain parallel to the axes), and (3) the bounding box to the rotated object with sides parallelTHE VOIGT PROFILE
The Voigt profile. The Voigt line profile occurs in the modelling and analysis of radiative transfer in the atmosphere. It is the convolution of a Gaussian profile, G ( x; σ) and a Lorentzian profile, L ( x; γ) : ( − x 2 2 σ 2) a n d L ( x; γ) = γ / π x 2 + γ 2. 2. In terms of frequency, ν, x = ν − ν 0 where ν 0 isthe line centre.
THE JULIA SET
The Julia set associated with the complex function f ( z) = z 2 + c may be depicted using the following algorithm. For each point, z 0, in the complex plane such that − 1.5 ≤ Re. . ≤ 1.5 and − 1.5 ≤ Im. . ≤ 1.5, iterate according to z n + 1 = z n 2 + c where c is a some (complex) constant.TRUCHET TILES
Truchet Tiles. Truchet Tiles are decorated squares which can tile a plane to create a pattern. For example, the four tiles: can be placed at random orientations to yield a non-repeating pattern: Similarly the two types of tile consisting of two quarter-circles in diagonally-opposite vertices of a square: can be used to create thefollowing
A QUANTUM PARTICLE IN A GRAVITATIONAL FIELD A quantum particle in a gravitational field. Consider a particle of mass m moving in a constant gravitational field such that its potential energy at a height z above a surface is m g z. If the particle bounces elastically on the surface, the classical probability density corresponding to its position is. where z m a x is the maximumheight it
TWO-DIMENSIONAL INTERPOLATION WITH SCIPY.INTERPOLATE.GRIDDATA Two-dimensional interpolation with scipy.interpolate.griddata. The code below illustrates the different kinds of interpolation method available for scipy.interpolate.griddata using 400 points chosen randomly from an interesting function. import numpy as np from scipy.interpolate import griddata import matplotlib.pyplot as plt x =np.linspace(-1
THE HEIGHT OF LIQUID IN A SPHERICAL TANK Suppose a particular spherical tank has a radius R and is filled with a liquid to a height h. It is (fairly) easy to find a formula for the volume of liquid from the height: V = π R h 2 − 1 3 π h 3. Suppose that there is a constant flow of liquid from the tank at a rate F =− d V / d t.
THE MADHAVA SERIES
Use a for loop to estimate π from the first 20 terms of the Madhava series : π = 12 ( 1 − 1 3 ⋅ 3 + 1 5 ⋅ 3 2 − 1 7 ⋅ 3 3 +⋯).
VISUALIZING THE GRADIENT DESCENT METHOD Visualizing the gradient descent method. In the gradient descent method of optimization, a hypothesis function, h θ ( x), is fitted to a data set, ( x ( i), y ( i)) ( i = 1, 2, ⋯, m) by minimizing an associated cost function, J ( θ) in terms of the parameters θ = θ 0, θ 1, ⋯. The cost function describes how closely the hypothesisfits
Toggle Navigation
Everything Blog posts Pages* Home
* About
* The Author
* The Book
* This Website
* Book
* Chapter 1: Introduction * Chapter 2: The Core Python Language I* Examples
* Questions
* Problems
* Additional Problems * Chapter 3: Simple Plotting with pylab* Examples
* Problems
* Chapter 4: The core Python language II* Examples
* Questions
* Problems
* Additional Problems * Chapter 5: IPython and IPython Notebook* Examples
* Chapter 6: NumPy
* Examples
* Questions
* Problems
* Additional Examples * Additional Problems * Chapter 7: Matplotlib* Examples
* Questions
* Problems
* Chapter 8: SciPy
* Examples
* Questions
* Problems
* Additional Examples * Additional Problems * Chapter 9: General Scientific Programming* Examples
* Questions
* Problems
* Errata
* Blog
* Apps
* Contact
LEARNING SCIENTIFIC PROGRAMMING WITH PYTHON Visualizing the Earth's dipolar magnetic field Impact craters on Earth Two-dimensional collisions Packing circles inside a shape Packing circles in a circle Simulating two-dimensional polycrystals Breeding tritium for a fusion reactor Diffusion on the surface of a torus Non-linear least squares fitting of a two-dimensional data ExB drift for an arbitrary electric potential Depicting a torus as an SVG imageReaching Orbit
Moiré patterns in a pair of hexagonal lattices Gyromotion of a charged particle in a magnetic fieldTypes of plasma
Plotting nuclear fusion cross sections Simulating the Belousov-Zhabotinsky reactionThe double pendulum
Visualizing the bivariate Gaussian distribution Visualizing the gradient descent method Computer generated contemporary art Simulating foraminifera Log in or Sign upRECENT TWEETS
*
SCIPYTHON3 @SCIPYTHON3 Visualizing linear transformations on a two-dimensional plane with #Python and #Matplotlib : https://t.co/99ZIj32JVL https://t.co/t0hupXGgZe 2 hours, 52 minutes ago*
SCIPYTHON3 @SCIPYTHON3 Your own, customizable #what3words geocoding system, in#Python :
https://t.co/9Q3AnKG3o2 (The White House is at respectable.ascii.dropped) 1 week, 4 days ago*
SCIPYTHON3 @SCIPYTHON3 Visualizing the Earth's magnetic field with #Pythonand #Matplotlib
https://t.co/y91CmDPttR https://t.co/oufvrGw2AN 1 week, 5 days agoDetails
Copyright © 2024 ArchiveBay.com. All rights reserved. Terms of Use | Privacy Policy | DMCA | 2021 | Feedback | Advertising | RSS 2.0