text:
# 「PyTorch」：4-Neural Network Design

PyTorch框架学习。

colab笔记：

Overview：

• Build PyTorch CNN - Object Oriented Neural Networks
• CNN Layers - Deep Neural Network Architecture
• CNN Weights - Learnable Parameters in Neural Networks
• Callable Neural Networks - Linear Layers in Depth
• CNN Forward Method - Deep Learning Implementation
• Forward Propagation Explained - Pass Image to PyTorch Neural Network
• Neural Network Batch Processing - Pass Image Batch to PyTorch CNN
• CNN Output Size Formula - Bonus Neural Network Debugging Session

# Building Neural Networks With PyTorch

From a high-level perspective or bird’s eye view of our deep learning project, we prepared our data, and now, we are ready to build our model.

【从高层次看，这一部分主要讲解如何用PyTorch设计model】

• Prepare the data
• Build the model
• Train the model
• Analyze the model’s results

We’ll do a quick OOP review in this post to cover the details needed for working with PyTorch neural networks, but if you find that you need more, the Python docs have an overview tutorial here.

【OOP的细节】

### PyTorch’s torch.nn Package

To build neural networks in PyTorch, we use the torch.nn package, which is PyTorch’s neural network (nn) library. We typically import the package like so:

PyTorch’s neural network library contains all of the typical components needed to build neural networks.

【nn库包含所有构建NN的典型组件】

#### PyTorch’s nn.Module Class

As we know, deep neural networks are built using multiple layers. This is what makes the network deep. Each layer in a neural network has two primary components:

【NN中的每一layer都由代码（input tensor到output tensor 的转换）和权重（weights）组成，因此可以用OOP的思想来抽象表示。】

• A transformation (code)
• A collection of weights (data)

In fact, this is the case with PyTorch. Within the nn package, there is a class called Module, and it is the base class for all of neural network modules which includes layers.

【nn库的Module类是所有NN模型中Layers的父类，即所有networks都要继承nn.Modules类】

#### PyTorch nn.Modules Have A forward() Method

When we pass a tensor to our network as input, the tensor flows forward though each layer transformation until the tensor reaches the output layer. This process of a tensor flowing forward though the network is known as a forward pass.

【forward pass：tensor向前流，直至输出层】

Every PyTorch nn.Module has a forward() method, and so when we are building layers and networks, we must provide an implementation of the forward() method. The forward method is the actual transformation.

【所有layers 和 networks在继承nn.Module时，都要实现forward()接口，这个forward方法就是实际的输入到输出的转换】

#### PyTorch’s nn.functional Package

When we implement the forward() method of our nn.Module subclass, we will typically use functions from the nn.functional package. This package provides us with many neural network operations that we can use for building layers. In fact, many of the nn.Module layer classes use nn.functional functions to perform their operations.

【nn.functional包有很多实用的函数操作，可以帮助我们构建layers。事实上，nn.Module的许多子类就使用了nn.functional的方法来完成他们的操作。】

# Building A Neural Network In PyTorch

We now have enough information to provide an outline for building neural networks in PyTorch. The steps are as follows:

Short version:

1. Extend the nn.Module base class.【继承nn.Module类】
2. Define layers as class attributes.【定义layers作为该类的属性】
3. Implement the forward() method.【实现forward()接口】

More detailed version:

1. Create a neural network class that extends the nn.Module base class.
2. In the class constructor, define the network’s layers as class attributes using pre-built layers from torch.nn.
3. Use the network’s layer attributes as well as operations from the nn.functional API to define the network’s forward pass.

#### Define The Network’s Layers As Class Attributes

We’re building a CNN, so the two types of layers we’ll use are linear layers and convolutional layers.

Inside of our Network class, we have five layers that are defined as attributes. We have two convolutional layers, self.conv1 and self.conv2, and three linear layers, self.fc1, self.fc2, self.out.

【在Network中，有5个layers作为该类的attributes】

We used the abbreviation fc in fc1 and fc2 because linear layers are also called fully connected layers. They also have a third name that we may hear sometimes called dense. So linear, dense, and fully connected are all ways to refer to the same type of layer. PyTorch uses the word linear, hence the nn.Linear class name.

We used the name out for the last linear layer because the last layer in the network is the output layer.

【fc是fully connected layers的缩写，全连接层，nn.Linear】

【out是输出层。】

### Our CNN Layers

Each of our layers extends PyTorch’s neural network Module class. For each layer, there are two primary items encapsulated inside, a forward function definition and a weight tensor.

【每一layer都会继承PyTorch的Module类。对于每一layer，都会封装两个组件：forward函数和权重tensor】

The weight tensor inside each layer contains the weight values that are updated as the network learns during the training process.

【每一层的weitght tensor都包含在NN训练中更新的权重参数。】

PyTorch’s neural network Module class keeps track of the weight tensors inside each layer. The code that does this tracking lives inside the nn.Module class, and since we are extending the neural network module class, we inherit this functionality automatically.

【其中，权重tensor就是在训练NN中会更新的参数，Module类会自动跟踪其每一层的weight tensor】

### CNN Layer Parameters

#### Parameter Vs Argument

We’ll parameters are used in function definitions as place-holders while arguments are the actual values that are passed to the function. The parameters can be thought of as local variables that live inside a function.

【Parameters作为占位符用于函数定义，而Arguments是传递给函数的实际的值。】

#### Two Types Of Parameters

To better understand the argument values for these parameters, let’s consider two categories or types of parameters that we used when constructing our layers.

【在构建layers时，有两种参数】

1. Hyperparameters【超参数】
2. Data dependent hyperparameters【数据依赖超参数】

When we construct a layer, we pass values for each parameter to the layer’s constructor. With our convolutional layers have three parameters and the linear layers have two parameters.

【在构建layer时，我们向layer constructor传递参数。】

• Convolutional layers
• in_channels
• out_channels
• kernel_size
• Linear layers
• in_features
• out_features

#### Hyperparameters

In general, hyperparameters are parameters whose values are chosen manually and arbitrarily.

【hyperparameters是手动主观确定的参数。】

As neural network programmers, we choose hyperparameter values mainly based on trial and error and increasingly by utilizing values that have proven to work well in the past. For building our CNN layers, these are the parameters we choose manually.

【超参数往往是基于经验trial和误差error确定的.】

【在CNN中，我们需要确定这些参数。】

Parameter Description
kernel_size Sets the filter size. The words kernel and filter are interchangeable.
out_channels Sets the number of filters. One filter produces one output channel.
out_features Sets the size of the output tensor.

#### Data Dependent Hyperparameters

Data dependent hyperparameters are parameters whose values are dependent on data. The first two data dependent hyperparameters that stick out are the in_channels of the first convolutional layer, and the out_features of the output layer.

【依赖于数据的超参数。比如在第一个卷积层的in_channles和输出层的out_features参数的确定都依赖于数据。】

In general, the input to one layer is the output from the previous layer, and so all of the in_channels in the conv layers and in_features in the linear layers depend on the data coming from the previous layer.

【一个layer的输入依赖于前一层的输出。】

When we switch from a conv layer to a linear layer, we have to flatten our tensor. This is why we have 12*4*4.

#### Summary Of Layer Parameters

Layer Param name Param value The param value is
conv1 in_channels 1 the number of color channels in the input image.
conv1 kernel_size 5 a hyperparameter.
conv1 out_channels 6 a hyperparameter.
conv2 in_channels 6 the number of out_channels in previous layer.
conv2 kernel_size 5 a hyperparameter.
conv2 out_channels 12 a hyperparameter (higher than previous conv layer).
fc1 in_features 12 * 4 * 4 the length of the flattened output from previous layer.
fc1 out_features 120 a hyperparameter.
fc2 in_features 120 the number of out_features of previous layer.
fc2 out_features 60 a hyperparameter (lower than previous linear layer).
out in_features 60 the number of out_channels in previous layer.
out out_features 10 the number of prediction classes.

# CNN Weights - Learnable Parameters In Neural Networks

### Learnable Parameters

Learnable parameters are parameters whose values are learned during the training process.

【Learnable parameters是在训练中可以学习的参数。】

With learnable parameters, we typically start out with a set of arbitrary values, and these values then get updated in an iterative fashion as the network learns.

【从一个主观确定的值开始，在网络学习中迭代更新。】

Where are the learnable parameters?

We’ll the learnable parameters are the weights inside our network, and they live inside each layer.

【Learnable parameters存在在网络中的每一层，是在我们网络中的权重参数。】

### Getting An Instance The Network

Let’s grab an instance of our network class and see this.

After the object is initialized, we can then access our object using the network variable.

【获得一个网络的实例，即会自动运行__init__ 对其初始化。】

#### How Overriding Works

All Python classes automatically extend the object class. If we want to provide a custom string representation for our object, we can do it, but we need to introduce another object oriented concept called overriding.

【所有Python的类都会继承oobject class，可以重写该类的字符表达（string representation）。】

We can override Python’s default string representation using the __repr__ function. This name is short for representation.

【重写__repr__ 函数】

### What’s In The String Representation?

#### Convolutional Layers

For the convolutional layers, the kernel_size argument is a Python tuple (5,5) even though we only passed the number 5 in the constructor.

【kernel_size的值，确定filter的大小。当传递一个值时，默认为square filter。】

The stride is an additional parameter that we could have set, but we left it out. When the stride is not specified in the layer constructor the layer automatically sets it.

【kernel移动的stride如果没有设置会自动设置。】

#### Linear Layers

For the linear layers, we have an additional parameter called bias which has a default parameter value of true. It is possible to turn this off by setting it to false.

【linear layers还有一个自动设置为True的bias参数。】

### Accessing The Network’s Layers

Well, now that we’ve got an instance of our network and we’ve reviewed our layers, let’s see how we can access them in code.

【如何访问NN中的layers：当一般属性访问，每一层都会返回一个字符表达】

### Accessing The Layer Weights

Now that we have access to each of our layers, we can access the weights inside each layer.

【访问每一层的权重参数。】

#### PyTorch Parameter Class

PyTorch has a special class called Parameter. The Parameter class extends the tensor class, and so the weight tensor inside every layer is an instance of this Parameter class.

【PyTorch还有一个特殊的类：Parameter类。这个类继承了tensor类，所以每一层中的weight tensor实则都是Parameter类的实例。】

### Weight Tensor Shape

For the convolutional layers, the weight values live inside the filters, and in code, the filters are actually the weight tensors themselves.

【对卷积层来说，weight是在filter中的，而filter在代码中的体现就是weight tensor。】

The convolution operation inside a layer is an operation between the input channels to the layer and the filter inside the layer. This means that what we really have is an operation between two tensors.

【卷积操作实则就是input tensor 和filter 的weight tensor之间的操作。】

For the first conv layer, we have 1 color channel that should be convolved by 6 filters of size 5x5 to produce 6 output channels. This is how we interpret the values inside our layer constructor.

【对于第一个卷积层来说，有6个 5 * 5的filer，会生成6个输出channel。】

Inside our layer though, we don’t explicitly have 6 weight tensors for each of the 6 filters. We actually represent all 6 filters using a single weight tensor whose shape reflects or accounts for the 6 filters.

【但我们不会使用6个weight tensor来表示该卷积层的6个filters，而是使用一个单独的weight tensor来表示该层的所有filers。】

The second axis has a length of 1 which accounts for the single input channel, and the last two axes account for the height and width of the filter.

【weight tensor的第一维度表示filters的数量，该tensor把所有filters都打包在一起。第二维度认为是filter的depth，和输入tensor的channel相同，最后两维为height 和width】

The two main takeaways about these convolutional layers is that our filters are represented using a single tensor and that each filter inside the tensor also has a depth that accounts for the input channels that are being convolved.

【卷积层的两个要点（takeways）】

1. All filters are represented using a single tensor.【用一个tensor表示该层的所有filters】
2. Filters have depth that accounts for the input channels.【其中每一个filter有depth，值等于输入的channels】

### Weight Matrix

With linear layers or fully connected layers, we have flattened rank-1 tensors as input and as output. The way we transform the in_features to the out_features in a linear layer is by using a rank-2 tensor that is commonly called a weight matrix.

【对于全连接层，我们需要拉直（flatten）输入/输出为rank-1的tensor】

【这种在全连接层中in_features到out_features的转换，使用weight matrix来实现，所以该层的参数就是一个rank-2的tensor】

#### Linear Function Represented Using A Matrix

The important thing about matrix multiplications like this is that they represent linear functions that we can use to build up our neural network.

Specifically, the weight matrix is a linear function also called a linear map that maps a vector space of 4 dimensions to a vector space of 3 dimensions.

【矩阵乘法实则是线性函数。具体来说，矩阵乘法也称为一个线性映射，将一个4D vector映射为一个3D vector。】

### Accessing The Networks Parameters

【访问NN的所有参数】

The first example is the most common way, and we’ll use this to iterate over our weights when we update them during the training process.

【遍历network.parameters()

The second way is just to show how we can see the name as well. This reveals something that we won’t cover in detail, the bias is also a learnable parameter. Each layer has a bias by default, so for each layer we have a weight tensor and a bias tensor.

【每一层中的bias也是一个可学习的参数。】

【遍历network.named_parameters()

# Callable Neural Networks - Linear Layers In Depth

In this one, we’ll learn about how PyTorch neural network modules are callable, what this means, and how it informs us about how our network and layer forward methods are called.

【在这一节中，我们能知道在network和layer中forward方法是如何调用的？】

### How Linear Layers Work

【使用矩阵乘法来转换】

#### Transform Using A PyTorch Linear Layer

【使用PyTorch Linear Layer来转换。】

【根据源码，在LinearLayer中会有一个3 * 4 的weight matrix】

Let’s see how we can call our layer now by passing the in_features tensor.

【直接传tensor来调用该layer】

We can call the object instance like this because PyTorch neural network modules are callable Python objects.

【因为PyTorch中的module是可以调用的类，即类中有__call__ 方法。

Let’s explicitly set the weight matrix of the linear layer to be the same as the one we used in our other example.

【可以单独设置linear layer中weight matrix的值】

### Callable Layers And Neural Networks

【可调用的Layers和NN】

We pointed out before how it was kind of strange that we called the layer object instance as if it were a function.

【为什么可以将实例作为函数调用？】

What makes this possible is that PyTorch module classes implement another special Python function called __call__(). If a class implements the __call__() method, the special call method will be invoked anytime the object instance is called.

【如果该类实现了__call()__ 方法，那么该类的实例就可以作为函数调用】

This fact is an important PyTorch concept because of the way the __call__() method interacts with the forward() method for our layers and networks.

【而PyTorch中该类的__call__ 方法是和forward() 方法交互的】

The extra code that PyTorch runs inside the __call__() method is why we never invoke the forward() method directly. If we did, the additional PyTorch code would not be executed. As a result, any time we want to invoke our forward() method, we call the object instance. This applies to both layers, and networks because they are both PyTorch neural network modules.

【因为有__call__() ，所以不需要直接调用forward() 方法。所以，如果任何时候我们想要调用forward() 方法时，我们都调用对象实例。】

## CNN Forward Method - PyTorch Deep Learning Implementation

Colab: CNN Forward Method

We created our network by extending the nn.Module PyTorch base class, and then, in the class constructor, we defined the network’s layers as class attributes. Now, we need to implement our network’s forward() method, and then, finally, we’ll be ready to train our model.

【前面通过继承nn.Module 来构建model，在model的构造器中，定义网络的layer作为model的属性。而构建model的最后一步是实现model中的forward() 方法】

【步骤】

• Prepare the data

• Build the model

1. Create a neural network class that extends the nn.Module base class.

2. In the class constructor, define the network’s layers as class attributes.

3. Use the network’s layer attributes as well nn.functional API operations to define the network’s forward pass.

【用网络的layer属性和nn.functional 库的激活函数等来定义网络的前向传播】

• Train the model

• Analyze the model’s results

### Implementing The forward() Method

【实现forward()方法】

#### Input Layer #1

The input layer of any neural network is determined by the input data.

【input layer 依赖于输入的数据】

For this reason, we can think of the input layer as the identity transformation. Mathematically, this is the function, $f(x)=x$ .

【可以把input layer看作identification transformation】

#### Hidden Convolutional Layers: Layers #2 And #3

Each of these layers is comprised of a collection of weights (data) and a collection operations (code). The weights are encapsulated inside the nn.Conv2d() class instance. The relu() and the max_pool2d() calls are just pure operations.

【每一层都是weights和operations的组合，weights封装在nn.Conv2d实例中，而relu()和max_pool2d()都是单纯的operations】

For example, we’ll say that the second layer in our network is a convolutional layer that contains a collection of weights, and preforms three operations, a convolution operation, the relu activation operation, and the max pooling operation.

【只是其中的一种表示：认为卷积层有一组weights（layer中包含的weights），三组操作：卷积操作、relu操作和max pooling 操作。】

Mathematically, the entire network is just a composition of functions, and a composition of functions is a function itself. So a network is just a function. All the terms like layers, activation functions, and weights, are just used to help describe the different parts.

【整个网络，其实就是functions的组合。因此，network本身就是一个function。layers, activation functions, weights只是来帮助描述这个function】

#### Hidden Linear Layers: Layers #4 And #5

Before we pass our input to the first hidden linear layer, we must reshape() or flatten our tensor. This will be the case any time we are passing output from a convolutional layer as input to a linear layer.

【在将卷积层的输出传递给全连接层之前，需要将他flatten】

#### Output Layer #6

The sixth and last layer of our network is a linear layer we call the output layer. When we pass our tensor to the output layer, the result will be the prediction tensor.

【第六层是输出层，该层的输出是一个有10个元素的tensor】

Inside the network we usually use relu() as our non-linear activation function, but for the output layer, whenever we have a single category that we are trying to predict, we use softmax(). The softmax function returns a positive probability for each of the prediction classes, and the probabilities sum to 1.

【前面的层我们都是用relu()来作为非线性函数，但输出层需要得到每一类的预测值，因此使用softmax()】

【softmax能返回每一类的预测概率，所有类的概率和为1】

# Forward Propagation Explained

### Forward Propagation Explained

Forward propagation is the process of transforming an input tensor to an output tensor.

【前馈传播是将输入tensor转换为输出tensor的过程。】

### Predicting With The Network: Forward Pass

Before we being, we are going to turn off PyTorch’s gradient calculation feature. This will stop PyTorch from automatically building a computation graph as our tensor flows through the network.

The computation graph keeps track of the network’s mapping by tracking each computation that happens. The graph is used during the training process to calculate the derivative (gradient) of the loss function with respect to the network’s weights.

【计算图通过跟踪计算来跟踪网络图，该计算图在训练过程中用于计算损失函数对权重参数的梯度。】

Since we are not training the network yet, we aren’t planning on updating the weights, and so we don’t require gradient calculations. We will turn this back on when training begins.

【因为我们还没有训练网络，所以我们并不打算更新参数，也就不需要梯度计算。】

#### Passing A Single Image To The Network

Let’s continue by creating an instance of our Network class:

【创建NN实例】

Next, we’ll procure a single sample from our training set, unpack the image and the label, and verify the image’s shape:

【从training set中生成一个单独的例子。】

Now, there’s a second step we must preform before simply passing this tensor to our network. When we pass a tensor to our network, the network is expecting a batch, so even if we want to pass a single image, we still need a batch.

【第二步，网络期望传递的tensor是一批，因此需要将单独的例子也打包。】

For each input in the batch, and for each prediction class, we have a prediction value. If we wanted these values to be probabilities, we could just the softmax() function from the nn.functional package.

【用F.softmax()将预测值转换为概率。】

### Neural Network Batch Processing With PyTorch

• Prepare the data
• Build the model
• Understand how batches are passed to the network
• Train the model
• Analyze the model’s results

Colab: Pass A Batch of Images

### Using Argmax: Prediction Vs Label

Colab: Pass A Batch of Images

## CNN Output Size Formula

### CNN Output Size Formula

#### CNN Output Size Formula (Square)

• Suppose we have an $n\times n$ input.【输入尺寸】
• Suppose we have an $f\times f$ filter.【filter尺寸】
• Suppose we have a padding of $p$ and a stride of $s$ .【padding和stride】

The output size $O$ is given by this formula: $O = \frac{n-f+2p}{s}+1$ 【输出】

#### CNN Output Size Formula (Non-Square)

• Suppose we have an $n_h×n_w$ input.
• Suppose we have an $f_h×f_w$ filter.
• Suppose we have a padding of $p$ and a stride of $s$.

The height of the output size $O_h$ is given by this formula:$O_h = \frac{n_h-f_h+2p}{s}+1$

The width of the output size $O_w$ is given by this formula: $O_w = \frac{n_w-f_w+2p}{s}+1$

「PyTorch」：4-Neural Network Design

https://f7ed.com/2021/02/28/pytorch-nn-design/

f1ed

2021-02-28

2021-02-28


text:
# Exercise ID368

Thinking Operations → Logic → Basic Logical Operations

Determine the true value of the following expressions:

$p\equiv \frac{3+2x}{3}-\frac{2-3x}{4}=\frac{29}{24};x=0,5$

$q\equiv 3\left(5-y\right)-2\left(y-1\right)=1+3y;y=2$Then determine the true value of the following two terms:

a) $\left(p\vee q\right)\wedge p$

b) $\left(p\wedge q\right)\vee p$

format: plain


text:
# Integration Question

Ed Aboud

## Homework Statement

$$\int \frac{sin(\sqrt{x})}{\sqrt{x}} dx$$

## The Attempt at a Solution

I'm not too sure how to approach this. The only thing that rings a bell at this moment is

$$\lim_{x\to\0} \frac{sinx}{x} = 1$$

and I don't feel that it is of any relevance.

Thanks

## Answers and Replies

Homework Helper
Gold Member
Use the substitution u = √x. Whats du?

Ed Aboud
So $$du = \frac{dx}{2\sqrt{x}}$$

$$2 \int sin(u) du$$

Cool, thanks.


text:
# How and why can more volatile acids be made with sulfuric acid? [duplicate]

This question already has an answer here:

I have read that sulfuric acid has low volatility. Then it states that more volatile acids can be made using sufuric acid and their corresponding salts, because of the low volatility.

Can you help me understand the chemistry behind the second statement?

## marked as duplicate by airhuff, Todd Minehardt, bon, paracetamol, ronMay 13 '17 at 17:37

• The gist is that you could take concentrated sulfuric acid, dilute it 50:50 by volume with water and add sodium chloride. You could then boil off HCl. Not an efficient way to get HCl but it would work. – MaxW Sep 15 '16 at 6:28
• What does volatility have to do here? – Hani Mohammed Sep 15 '16 at 6:29
• What is boiling off in the reactions I outlined? Sulfuric acid or hydrochloric acid? Isn't the first one to boil off "more volatile"? – MaxW Sep 15 '16 at 6:31

An acid according to the Brønsted-Lowry definition is any substance that can release $$\ce{H+}$$ ions. By having done so, it becomes a Brønsted-Lowry (conjugate) base which can accept $$\ce{H+}$$ ions. This is shown in equation $$(1)$$:

$$\begin{array}{ccccc}\ce{HA} & \ce{<=>} & \ce{H+} & + & \ce{A-}\\ \text{acid} & & \text{proton} & & \text{conjugate base}\end{array}\tag{1}$$

As already hinted, a Brønsted base is any substance that can accept such an incoming $$\ce{H+}$$ ion (reaction $$(2)$$)— as such, an acid will always react with a base and vice-versa; it is not possible for only an acidic reaction to happen.

$$\begin{array}{ccccc}\ce{B} & + & \ce{H+} & \ce{<=>} & \ce{HB+}\\ \text{base} & & \text{proton} & & \text{conjugate acid}\end{array}\tag{2}$$

Let me quickly quote part of the question:

[M]ore volatile acids can be made using sulphuric acid and their corresponding salts

The corresponding salt of a more volatile acid could also be termed its conjugate base. So the reaction we are talking about includes the conjugate base of one acid and sulphuric acid as a second acid. To exemplify things, I will use hydrochloric acid as the first acid whose conjugate base is chloride. If we thus mix chloride ions (e.g. in sodium chloride) with sulphuric acid, the following equilibrium will result:

$$\ce{Cl- + H2SO4 <=> HCl + HSO4-}\tag{3}\\[1.2em] K = \frac{[\ce{HCl}][\ce{HSO4-}]}{[\ce{Cl-}][\ce{H2SO4}]} = \frac{K_\mathrm{a} \left ( \ce{H2SO4} \right )}{K_\mathrm{a} \left ( \ce{HCl} \right )}$$

The equilibrium constant $$K$$ is the ratio of the acid constants of hydrochloric and sulphuric acid. Since hydrochloric acid ($$\mathrm{p}K_\mathrm{a} \approx -8$$) is more acidic than sulphuric acid ($$\mathrm{p}K_\mathrm{a} \approx -3$$), we expect the equilibrium to be shifted towards the reactant side — which would be true for a closed, pressurised system. Once we open the system, and allow for gases to be exchanged, the picture changes. Compare equation $$(\text{3'})$$, wherein the aggregate states of the reaction partners are mentioned.

$$\ce{Cl- (s) + H2SO4 (l) <=> HCl (g) ^ + HSO4- (s)}\tag{3'}$$

Hydrochloric acid is a gas and can diffuse away while sulphuric acid is a liquid and thus cannot diffuse away. (And cannot drip away since we are using a proper beaker of some kind.) If we constantly remove $$\ce{HCl}$$ from the reaction mixture by letting it diffuse away, we are exercising pressure onto the system, and per Le Châtelier’s principle the product side (one of whose species we are removing) will now be favoured.

This general principle applies to any acid, as long as it is more volatile than sulphuric acid, i.e. has a lower boiling point under the pressure used. If the second acid happens to be liquid rather than gaseous, a simple distillation will suffice to remove it from the reaction mixture.


text:
# VIBRATIONALLY RESOLVED NEGATIVE ION PHOTOELECTRON SPECTROSCOPIC STUDIES OF NIOBIUM CLUSTERS

Please use this identifier to cite or link to this item: http://hdl.handle.net/1811/13768

Files Size Format View
1996-WH-12.jpg 133.0Kb JPEG image

 Title: VIBRATIONALLY RESOLVED NEGATIVE ION PHOTOELECTRON SPECTROSCOPIC STUDIES OF NIOBIUM CLUSTERS Creators: Green, S. M. E.; Alex, S.; Leopold, D. G. Issue Date: 1996 Abstract: Negative ion photoelectron spectroscopy provides a means of obtaining vibrational data for atoms and small molecules ""chemisorbed"" on size-selected metal clusters. In the present study, $Nb_{3}O^{-}$, $Nb_{4}O^{-}$ and $Nb_{4}CO^{-}$ were prepared in a flowing afterglow ion-molecule reactor equipped with a metal cathode cluster source. The 488 nm photoelectron spectrum of the mass-selected $Nb_{3}O^{-}$ anions shows a vertical transition to the ground state of neutral $Nb_{3}O^{-}$, with weak progressions in the $Nb_{3}-O$ stretching (710$\pm$$20 cm^{-1} in Nb_{3}O) and Nb_{3} bending (320\pm$$15 cm^{-1}$ in both $Nb_{3}O$ and $Nb_{3}O^{-}$) vibrational modes. These results indicate that the $Nb_{3}O^{-}$ anion, like $Nb_{3}O$ and $Nb_{3}O^{-1}$, has a planar $C_{3}$, structure with the O atom bridging two Nb atoms. The $Nb_{4}O^{-}$ spectrum shows resolved transitions to the ground state of $Nb_{4}O$ and to an excited electronic state lying 3050$\pm$$20 cm^{-1} higher in energy. In analogy with Nb_{3}O results, the 670\pm$$20 cm^{-1}$ frequencies observed in the ground and excited states, respectively, to a bending mode of the metal cluster. The electron affinities of $Nb_{3}O$ and $Nb_{4}O$ are 1.402 and 1.178 ($\pm$0.006) cV, respectively. Preliminary, ongoing studies of mass selected $Nb_{4}CO^{-}$ anions prepared under a variety of source conditions thus far suggest the presence of two isomers, one with a greatly weakened but intact CO bond as indicated by a very low CO stretching frequency of about $1300 cm^{-1}$, and the other with the dissociated C and O atoms bound separately to the niobium cluster. URI: http://hdl.handle.net/1811/13768 Other Identifiers: 1996-WH-12


text:
# Question #2007311: Other Economics Problems

Question: (i) A competitive firm’s total cost function is given by

$TC=0.25{{Q}^{2}}+25$

(with MC = .5Q).

The firm faces a market price of $15. Algebraically calculate the profit maximizing output and the level of optimal profit for the firm (ii) Suppose that fixed costs increase by$50 but the prevailing market price remains unchanged. Using algebra determine the effects of this change in cost on the profit maximizing output and the optimal profit. Do you see any change from your answer to (i) above? Explain why or why not.

Solution: The solution consists of 184 words (2 pages)
Deliverables: Word Document

0


text:
How to specify assumptions before evaluation?

If I request mathematica evaluate an integral for me, I'll often get a more general ConditionalExpression than I want. Example :

Clear[ii, u, z, l, jj]
ii = Integrate[ 1 / Sqrt[z^2 + u^2], {z, -l, l}]

ConditionalExpression[ -Log[-l + Sqrt[l^2 + u^2]] + Log[l + Sqrt[l^2 + u^2]],
Re[u/l] != 0 || Im[u/l] >= 1 || Im[u/l] <= -1]

I can reduce this after the fact with something like:

jj = FullSimplify[ii, u > 0 && l > 0 && Element[ u | l, Reals] ]

Log[(u^2 + 2 l (l + Sqrt[l^2 + u^2]))/u^2]

but I'd imagine it should often simplify the calculations if I could provide the assumptions up front, especially the obvious ones like restricting various variables to the domain of reals.

Is there a way to do this?

-

Integrate can take the option Assumptions.

Integrate[1/Sqrt[z^2 + u^2], {z, -l, l},
Assumptions -> u > 0 && l > 0 && Element[u | l, Reals]]

==> 2 Log[(l + Sqrt[l^2 + u^2])/u]

Alternatively use Assuming.

Assuming[u > 0 && l > 0 && Element[u | l, Reals],
Integrate[1/Sqrt[z^2 + u^2], {z, -l, l}]]

==> 2 Log[(l + Sqrt[l^2 + u^2])/u]

-

For Integrate as well as for Simplify, Refine FunctionExpand, Limit etc. there is an option Assumptions:

Integrate[ 1/Sqrt[ z^2 + u^2], {z, -l, l}, Assumptions -> (u | l) ∈ Reals]

ConditionalExpression[ 2 ArcSinh[ l/Abs[ u]], u != 0 && l >= 0]

or one can use

Assuming[ (u | l) ∈ Reals, Integrate[ 1/Sqrt[ z^2 + u^2], {z, -l, l}]]

the latter is more handy for CompoundExpression's, e.g.

Assuming[ (u | l) ∈ Reals,
int = Integrate[1/Sqrt[z^2 + u^2], {z, -l, l}]; Simplify[int, int[[2]]] ]

2 ArcSinh[ l/Abs[ u]]

Another way of making assumptions is to use $Assumptions globally in a Mathematica session or to close it in Block, e.g. Block[{$Assumptions = (u | l) ∈ Reals},
Integrate[ 1/Sqrt[ z^2 + u^2], {z, -l, l}]]

Edit

The integral in the question provides a good example for a throughout discussion of assumptions methods like Assumptions, Assuming or $Assumptions. The OP seems to need the integral in the real domain and if not specified explicitely in general Mathematica evaluates integrals by default in complex numbers. • u > 0 and l > 0 implies Element[u | l, Reals], thus we need not to add this assumption :  Integrate[ 1/Sqrt[ z^2 + u^2], {z, -l, l}, Assumptions -> u > 0 && l > 0]  2 Log[( l + Sqrt[ l^2 + u^2])/u]  • Element[u | l, Reals] is a more general assumption, and when we use it in Assuming or adding such Assumptions in Integrate we obtain a slightly more general expression. To see it we write : ComplexExpand[ 2 ArcSinh[ l/Abs[ u]]]  2 I Arg[Sqrt[ 1 + l^2/Abs[ u]^2] + l/Abs[ u]] + Log[(Sqrt[1 + l^2/Abs[u]^2] + l/Abs[u])^2]  then we can impose a stronger assumption, to get what we get using Assumptions in Integrate :  Refine[ %, l ∈ Reals && u > 0]   2 Log[ Sqrt[ 1 + l^2/u^2] + l/u ]  We could also get this with FunctionExpand using u > 0 and then passing it to TrigToExp: FunctionExpand[ 2 ArcSinh[ l /Abs[ u]], u > 0] // TrigToExp  - Good point about the inequalities implicitly assuming Reals +1. – Andy Ross Feb 28 '12 at 4:01 @AndyRoss Thanks ! Such issues are ubiquitous, making a good CAS is a really hard task. – Artes Feb 28 '12 at 4:13 Thanks for the mention of$Assumptions. That looks very handy. –  Peeter Joot Feb 28 '12 at 16:59
@Artes Considering your answer, I don't understand why Assuming[x>0,TrueQ[x>0]] does reply False. Could you please explain? –  max Mar 26 '12 at 22:35
@max When you evaluate only TrueQ[x > 0] outside Assuming you get False since TrueQ may have only logical values and while you haven't assigned any value to x it has to return False. Assuming[cond, eqn] is supposed to work with equations or mathematical functions which return numerical values. Nevertheless when you set e.g. x=5 then Assuming[x > 0, TrueQ[x > 0]] will return True unlike e.g. Assuming[x < 0, TrueQ[x < 0]] just because TrueQ is a logical operator not an equation and x has an assigned value. –  Artes Mar 26 '12 at 23:48


text:
# uncountable sums of positive numbers

The notion of sum of a series can be generalized to sums of nonnegative real numbers over arbitrary index sets.

let $I$ be a set and let $c$ be a mapping from $I$ to the nonnegative real numbers. Then we may define the sum as follows:

 $\sum_{i\in I}c_{i}=\sup_{s\subset I\atop\#s<\infty}\sum_{i\in s}c_{i}$

In words, we are taking the supremum over all sums over finite subsets of the index set. This agrees with the usual notion of sum when our set is countably infinite, but generalizes this notion to uncountable index sets.

An important fact about this generalization is that the sum can only be finite if the number of elements $i\in I$ such that $c_{i}>0$ is countable. To demonstrate this fact, define the sets $s_{n}$ (where n is a nonnegative integer) as follows:

 $s_{0}=\{i\in I\mid c_{i}\geq 1\}$

when $n>0$,

 $s_{n}=\{i\in I\mid 1/n>c_{i}\geq 1/(n+1)\}$

If any of these sets is infinite, then the sum will diverge so, for the sum to be finite, all these sets must be finite. However, if these sets are all finite, then their union is countable. In other words, the number of indices for which $c_{i}>0$ will be countable.

This notion finds use in places such as non-separable Hilbert spaces. For instance, given a vector in such a space and a complete orthonormal set, one can express the norm of the vector as the sum of the squares of its components using this definition even when the orthonormal set is uncountably infinite.

This discussion can also be phrased in terms of Lesbegue integration with respect to counting measure. For this point of view, please see the entry support of integrable function with respect to counting measure is countable.

Title uncountable sums of positive numbers UncountableSumsOfPositiveNumbers 2013-03-22 15:44:47 2013-03-22 15:44:47 rspuzio (6075) rspuzio (6075) 5 rspuzio (6075) Definition msc 40-00 SupportOfIntegrableFunctionWithRespectToCountingMeasureIsCountable


text:
Opuscula Math. 33, no. 4 (2013), 741-750
http://dx.doi.org/10.7494/OpMath.2013.33.4.741

Opuscula Mathematica

# Vulnerability parameters of tensor product of complete equipartite graphs

P. Paulraja
V. Sheeba Agnes

Abstract. Let $$G_{1}$$ and $$G_{2}$$ be two simple graphs. The tensor product of $$G_{1}$$ and $$G_{2}$$, denoted by $$G_{1}\times G_{2}$$, has vertex set $$V(G_{1}\times G_{2})=V(G_{1})\times V(G_{2})$$ and edge set $$E(G_{1}\times G_{2})=\{(u_{1},v_{1})(u_{2},v_{2}):u_{1}u_{2}\in E(G_{1})$$ and $$v_{1}v_{2}\in E(G_{2})\}$$. In this paper, we determine vulnerability parameters such as toughness, scattering number, integrity and tenacity of the tensor product of the graphs $$K_{r(s)}\times K_{m(n)}$$ for $$r\geq 3, m\geq 3, s\geq 1$$ and $$n\geq 1,$$ where $$K_{r(s)}$$ denotes the complete $$r$$-partite graph in which each part has $$s$$ vertices. Using the results obtained here the theorems proved in [Aygul Mamut, Elkin Vumar, Vertex Vulnerability Parameters of Kronecker Products of Complete Graphs, Information Processing Letters 106 (2008), 258-262] are obtained as corollaries.

Keywords: fault tolerance, tensor product, vulnerability parameters.

Mathematics Subject Classification: 05C76, 05C40.

Full text (pdf)

P. Paulraja, V. Sheeba Agnes, Vulnerability parameters of tensor product of complete equipartite graphs, Opuscula Math. 33, no. 4 (2013), 741-750, http://dx.doi.org/10.7494/OpMath.2013.33.4.741

a .bib file (BibTeX),
a .ris file (RefMan),
a .enw file (EndNote)
or export to RefWorks.

In accordance with EU legislation we advise you this website uses cookies to allow us to see how the site is used. All data is anonymized.
All recent versions of popular browsers give users a level of control over cookies. Users can set their browsers to accept or reject all, or certain, cookies.


text:
## Universality probability of a prefix-free machine

George Barmpalias and David L. Dowe

### Summary

We study the notion of universality probability of a universal prefix-free machine, as introduced by C.S. Wallace. We show that it is random relative to the fourth iterate of the halting problem and determine its Turing degree and its place in the arithmetical hierarchy of complexity. Furthermore, we give a computational characterization of the real numbers which are universality probabilities of universal prefix-free machines.


text:
Quantum nonlocality

In theoretical physics, quantum nonlocality is a characteristic of some measurements made at a microscopic level that contradict the assumptions of local realism found in classical mechanics. Despite consideration of hidden variables as a possible resolution of this contradiction, some aspects of entangled quantum states have been demonstrated irreproducible by any local hidden variable theory. Bell's theorem is one such demonstration which has been verified by experiment.[1]

Experiments have generally favoured quantum mechanics as a description of nature, over local hidden variable theories.[2][3] Any physical theory that supersedes or replaces quantum theory must make similar experimental predictions and must therefore also be nonlocal in this sense; quantum nonlocality is a property of the universe that is independent of our description of nature.

Quantum nonlocality does not allow for faster-than-light communication,[4] and hence is compatible with special relativity. However, it prompts many of the foundational discussions concerning quantum theory.

In October 2018, physicists reported that quantum behavior can be explained with classical physics for a single particle, but not for multiple particles as in quantum entanglement and related nonlocality phenomena.[5][6]

History

Einstein, Podolsky and Rosen

In 1935, Einstein, Podolsky and Rosen published a thought experiment with which they hoped to expose the incompleteness of the Copenhagen interpretation of quantum mechanics in relation to the violation of local causality at the microscopic scale that it described.[7] Afterwards, Einstein presented a variant of these ideas in a letter to Erwin Schrödinger,[8] which is the version that is presented here. The state and notation used here are more modern, and akin to Bohm's take on EPR.[9] The quantum state of the two particles prior to measurement can be written as

${\displaystyle \left|\psi _{AB}\right\rangle ={\frac {1}{\sqrt {2}}}{\bigg (}\left|0\right\rangle _{A}\left|1\right\rangle _{B}-\left|1\right\rangle _{A}\left|0\right\rangle _{B}{\bigg )}={\frac {1}{\sqrt {2}}}{\bigg (}\left|+\right\rangle _{A}\left|-\right\rangle _{B}-\left|-\right\rangle _{A}\left|+\right\rangle _{B}{\bigg )}}$

Where ${\displaystyle \left|\pm \right\rangle ={\frac {1}{\sqrt {2}}}\left(\left|0\right\rangle \pm \left|1\right\rangle \right)}$.[10]

Here, subscripts A and B distinguish the two particles, though it is more convenient and usual to refer to these particles as being in the possession of two experimentalists called Alice and Bob. The rules of quantum theory give predictions for the outcomes of measurements performed by the experimentalists. Alice, for example, will measure her particle to be spin-up in an average of fifty percent of measurements. However, according to the Copenhagen interpretation, Alice's measurement causes the state of the two particles to collapse, so that if Alice performs a measurement of spin in the z-direction, that is with respect to the basis ${\displaystyle \{\left|0\right\rangle _{A},\left|1\right\rangle _{A}\}}$, then Bob's system will be left in one of the states ${\displaystyle \{\left|0\right\rangle _{B},\left|1\right\rangle _{B}\}}$. Likewise, if Alice performs a measurement of spin in the x-direction, that is with respect to the basis ${\displaystyle \{\left|+\right\rangle _{A},\left|-\right\rangle _{A}\}}$, then Bob's system will be left in one of the states ${\displaystyle \{\left|+\right\rangle _{B},\left|-\right\rangle _{B}\}}$. Schrödinger referred to this phenomenon as "steering".[11] This steering occurs in such a way that no signal can be sent by performing such a state update; quantum nonlocality cannot be used to send messages instantaneously and is therefore not in direct conflict with causality concerns in Special Relativity.[10]

In the Copenhagen view of this experiment, Alice's measurement—and particularly her measurement choice—have a direct effect on Bob's state. However, under the assumption of locality, actions on Alice's system do not affect the "true", or "ontic" state of Bob's system. We see that the ontic state of Bob's system must be compatible with one of the quantum states ${\displaystyle \left|\uparrow \right\rangle _{B}}$ or ${\displaystyle \left|\downarrow \right\rangle _{B}}$, since Alice can make a measurement that concludes with one of those states being the quantum description of his system. At the same time, it must also be compatible with one of the quantum states ${\displaystyle \left|\leftarrow \right\rangle _{B}}$ or ${\displaystyle \left|\rightarrow \right\rangle _{B}}$ for the same reason. Therefore, the ontic state of Bob's system must be compatible with at least two quantum states; the quantum state is therefore not a complete descriptor of his system. Einstein, Podolsky and Rosen saw this as evidence of the incompleteness of the Copenhagen interpretation of quantum theory, since the wavefunction is explicitly not a complete description of a quantum system under this assumption of locality. Their paper concludes:[7]

While we have thus shown that the wave function does not provide a complete description of the physical reality, we left open the question of whether or not such a description exists. We believe, however, that such a theory is possible.

Although various authors (most notably Niels Bohr) criticised the ambiguous terminology of the EPR paper,[12][13] the thought experiment nevertheless generated a great deal of interest. Their notion of a "complete description" was later formalised by the suggestion of hidden variables that determine the statistics of measurement results, but to which an observer does not have access.[14] Bohmian mechanics provides such a completion of quantum mechanics, with introduction of hidden variables; however the theory is explicitly nonlocal.[15] The interpretation therefore does not give an answer to Einstein's question, which was whether or not a complete description of quantum mechanics could be given in terms of local hidden variables in keeping with the "Principle of Local Action".[16]

Probabilistic Nonlocality

In 1964 John Bell answered Einstein's question by showing that such local hidden variables can never reproduce the full range of statistical outcomes predicted by quantum theory.[17] Bell showed that a local hidden variable hypothesis leads to restrictions on the strength of correlations of measurement results. If the Bell inequalities are violated experimentally as predicted by quantum mechanics, then reality cannot be described by local hidden variables and the mystery of quantum nonlocal causation remains. According to Bell:[17]

This [grossly nonlocal structure] is characteristic ... of any such theory which reproduces exactly the quantum mechanical predictions.

Clauser, Horne, Shimony and Holt (CHSH) reformulated these inequalities in a manner that was more conducive to experimental testing (see CHSH inequality).[18] They proposed a scheme whereby two experimentalists, Alice and Bob, make separate measurements of photon polarization in two carefully chosen directions, and derived a simple inequality that is obeyed by all local hidden variable theories, but violated by certain measurements on quantum states.

Bell formalized the idea of a hidden variable by introducing the parameter λ to locally characterize measurement results on each system:[17] "It is a matter of indifference ... whether λ denotes a single variable or a set ... and whether the variables are discrete or continuous". However, it is equivalent (and more intuitive) to think of λ as a local "strategy" or "message" that occurs with some probability ρ(${\displaystyle \lambda }$) when an entangled pair of states is created. EPR's criteria of local separability then stipulates that each local strategy defines the distributions of independent outcomes if Alice measures in direction A and Bob measures in direction B:[17]

${\displaystyle P\left({a,b}{|}{A,B,\lambda }\right)=P\left({a}{|}{A,\lambda }\right)P\left({b}{|}{B,\lambda }\right)}$

where, for instance, ${\displaystyle \scriptstyle P\left({a}{|}{A,\lambda }\right)}$ denotes the probability of Alice getting the outcome a given λ, and that she measured A.

Suppose that λ can take values from some set ${\displaystyle \lambda _{i}}$, where 1 ≤ i ≤ k. If each ${\displaystyle \lambda _{i}}$ has an associated probability ρ(${\displaystyle \lambda _{i}}$) of being selected (such that the probabilities sum to unity) we can average over this distribution to obtain a formula for the joint probability of each measurement result:

${\displaystyle P\left({a,b}{|}{A,B}\right)=\sum _{i=1}^{k}P\left({a,b}{|}{A,B,\lambda _{i}}\right)\rho \left(\lambda _{i}\right)\,.}$

In the CHSH scheme, the measurement result for the polarization of a photon can take one of two values (informally, whether the photon is polarized in that direction, or in the orthogonal direction). We encode this by allowing a and b to take on values ±1. For arbitrary measurements A and B, their correlator E(A, B) is then defined as

${\displaystyle E\left({A,B}\right)=\sum _{a,b}abP\left({a,b}{|}{A,B}\right)\,.}$

Note that the product ab is equal to 1 if Alice and Bob get the same outcome, and −1 if they get different outcomes. The correlator E(A,B) can therefore be seen as the expectation that Alice's and Bob's outcomes are correlated. In the case that Alice chooses from one of two measurements ${\displaystyle A_{0}}$ or ${\displaystyle A_{1}}$, and Bob chooses from ${\displaystyle B_{0}}$ or ${\displaystyle B_{1}}$, the CHSH value for this joint probability distribution is defined as

${\displaystyle S_{CHSH}=E\left({A_{0},B_{0}}\right)+E\left({A_{0},B_{1}}\right)+E\left({A_{1},B_{0}}\right)-E\left({A_{1},B_{1}}\right)\,.}$

Compare this with the expression ${\displaystyle \scriptstyle x\oplus y=XY}$ and the discussion in the above example. The CHSH value ${\displaystyle S_{CHSH}}$ includes a negative contribution of the correlator whenever ${\displaystyle A_{1}}$ and ${\displaystyle B_{1}}$ are chosen (${\displaystyle x=y}$ when ${\displaystyle XY=1}$), and a positive contribution in all other cases (${\displaystyle x}$${\displaystyle y}$ when ${\displaystyle XY=0}$). If the joint probability distribution can be described with local strategies as above, it can be shown that the correlation function always obeys the following CHSH inequality:[10]

${\displaystyle -2\leq S_{CHSH}\leq 2\,.}$

However, if instead of local hidden variables we adopt the rules of quantum theory, it is possible to construct an entangled pair of particles (one each for Alice and Bob) and a set of measurements ${\displaystyle \scriptstyle A_{0},A_{1},B_{0},B_{1}}$ such that ${\displaystyle \scriptstyle S_{CHSH}\;=\;2{\sqrt {2}}}$. This demonstrates an explicit way in which a theory with ontological states that are local, with local measurements and only local actions cannot match the probabilistic predictions of quantum theory, disproving Einstein's hypothesis. Experimentalists such as Alain Aspect have verified the quantum violation of the CHSH inequality,[2] as well as other formulations of Bell's inequality, to invalidate the local hidden variables hypothesis and confirm that reality is indeed nonlocal in the EPR sense.

Possibilistic Nonlocality

The demonstration of nonlocality due to Bell is probabilistic in the sense that it shows that the precise probabilities predicted by quantum mechanics for some entangled scenarios cannot be met by a local theory. (For short, here and henceforth "local theory" means "local hidden variables theory".) However, quantum mechanics permits an even stronger violation of local theories: a possibilistic one, in which we find that local theories cannot agree with quantum mechanics on which events are possible or impossible in an entangled scenario. The first proof of this kind was due to Greenberger, Horne and Zeilinger in 1993.[19] The state involved is often called the GHZ state.

In 1993, Lucien Hardy demonstrated a logical proof of quantum nonlocality that, like the GHZ proof is a possibilistic proof.[20][21][22] We note that the same state ${\displaystyle \left|\psi \right\rangle }$ defined below can be written in a few suggestive ways:

${\displaystyle \left|\psi \right\rangle ={\frac {1}{\sqrt {3}}}\left(\left|00\right\rangle +\left|01\right\rangle +\left|10\right\rangle \right)={\frac {1}{\sqrt {3}}}\left({\sqrt {2}}\left|+0\right\rangle +{\frac {1}{\sqrt {2}}}\left(\left|+1\right\rangle +\left|-1\right\rangle \right)\right)={\frac {1}{\sqrt {3}}}\left({\sqrt {2}}\left|0+\right\rangle +{\frac {1}{\sqrt {2}}}\left(\left|1+\right\rangle +\left|1-\right\rangle \right)\right)}$

where, as above, ${\displaystyle |\pm \rangle ={\tfrac {1}{\sqrt {2}}}(\left|0\right\rangle \pm \left|1\right\rangle )}$.

The experiment consists of this entangled state being shared between two experimenters, each of whom has the ability to measure either with respect to the basis ${\displaystyle \{\left|0\right\rangle ,\left|1\right\rangle \}}$ or ${\displaystyle \{\left|+\right\rangle ,\left|-\right\rangle \}}$. We see that if they each measure with respect to ${\displaystyle \{\left|0\right\rangle ,\left|1\right\rangle \}}$, then they never see the outcome ${\displaystyle \left|11\right\rangle }$. If one measures with respect to ${\displaystyle \{\left|0\right\rangle ,\left|1\right\rangle \}}$ and the other ${\displaystyle \{\left|+\right\rangle ,\left|-\right\rangle \}}$, they never see the outcomes ${\displaystyle \left|-0\right\rangle ,}$ ${\displaystyle \left|0-\right\rangle .}$ However, sometimes they see the outcome ${\displaystyle \left|--\right\rangle }$ when measuring with respect to ${\displaystyle \{\left|+\right\rangle ,\left|-\right\rangle \}}$, since ${\displaystyle \langle --|\psi \rangle =-{\tfrac {1}{2{\sqrt {3}}}}\neq 0.}$

This leads us to the paradox: having the outcome ${\displaystyle |--\rangle }$ we conclude that if one of the experimenters had measured with respect to the ${\displaystyle \{\left|0\right\rangle ,\left|1\right\rangle \}}$ basis instead, the outcome must have been ${\displaystyle |{-}1\rangle }$ or ${\displaystyle |1-\rangle }$, since ${\displaystyle |{-}0\rangle }$ and ${\displaystyle |0-\rangle }$ are impossible. But then, if they had both measured with respect to the ${\displaystyle \{\left|0\right\rangle ,\left|1\right\rangle \}}$ basis, by locality the result must have been ${\displaystyle \left|11\right\rangle }$, which is also impossible.

Differences between nonlocality and entanglement

In the media and popular science, quantum nonlocality is often portrayed as being equivalent to entanglement. While it is true that a pure bipartite quantum state must be entangled in order for it to produce nonlocal correlations, there exist entangled (mixed) states which do not produce such correlations,[23] and there exist non-entangled (namely, separable) states that do produce some type of non-local behavior.[24] For the former, a well-known example is constituted by a subset of Werner states that are entangled but whose correlations can always be described using local hidden variables. On the other hand, reasonably simple examples of Bell inequalities have been found for which the quantum state giving the largest violation is never a maximally entangled state, showing that entanglement is, in some sense, not even proportional to nonlocality.[25][26][27]

In short, entanglement of a two-party state is necessary but not sufficient for that state to be nonlocal. It is important to recognise that entanglement is more commonly viewed as an algebraic concept, noted for being a precedent to nonlocality as well as quantum teleportation and superdense coding, whereas nonlocality is interpreted according to experimental statistics and is much more involved with the foundations and interpretations of quantum mechanics.

Superquantum nonlocality

Whilst the CHSH inequality gives restrictions on the CHSH value attainable by local hidden variable theories, the rules of quantum theory do not allow us to violate Tsirelson's bound of ${\displaystyle \scriptstyle 2{\sqrt {2}}}$, even if we exploit measurements of entangled particles.[28] The question remained whether this was the maximum CHSH value that can be attained without explicitly allowing instantaneous signaling. In 1994 two physicists, Sandu Popescu and Daniel Rohrlich, formulated an explicit set of correlated measurements that respect the "non-signalling" principle, yet give ${\displaystyle S_{CHSH}=4}$: the algebraic maximum.[29] The maximal violation of CHSH consistent with no signalling was also found, earlier, by Rastall and Khalfin and Tsirelson.[30][31] This demonstrated that there exist formulatable theories that are "non-signalling", yet drastically violate the joint probability constraints of quantum theory. The attempt to understand what distinguishes quantum theory from such general theories motivated an abstraction from physical measurements of nonlocality, to the study of nonlocal boxes.[32]

Nonlocal boxes generalize the concept of experimentalists making joint measurements from separate locations. As in the discussion above, the choice of measurement is encoded by the input to the box. A two-party nonlocal box takes an input A from Alice and an input B from Bob, and outputs two values a and b for Alice and Bob respectively and separately, where a, b, A and B take values from some finite alphabet (normally ${\displaystyle \{0,1\}}$). The box is characterized by the probability of outputting pair a, b, given the inputs A, B. This probability is denoted ${\displaystyle \scriptstyle P\left({{a,b}{|}{A,B}}\right)}$ and obeys the normal probabilistic conditions of positivity and normalisation:[32]

${\displaystyle P\left({{a,b}{|}{A,B}}\right)\geq 0\quad \forall {a,b,A,B}}$

and

${\displaystyle \sum _{a,b}P\left({{a,b}{|}{A,B}}\right)=1\quad \forall {A,B}}$

A box is local, or admits a local hidden variable model, if its output probabilities can be characterized in the following way:[23]

${\displaystyle P\left({{a,b}{|}{A,B}}\right)=\sum _{\lambda }p(\lambda )\;P\left({{a}{|}{A,\lambda }}\right)\;P\left({{b}{|}{B,\lambda }}\right)}$

where ${\displaystyle \scriptstyle P\left({{a}{|}{A,\lambda }}\right)}$ and ${\displaystyle \scriptstyle P\left({{b}{|}{B,\lambda }}\right)}$ describe single input/output probabilities at Alice's or Bob's system alone, and the value of ${\displaystyle \lambda }$ is chosen at random according to some fixed probability distribution given by ${\displaystyle p(\lambda )}$. Intuitively, ${\displaystyle \lambda }$ corresponds to a hidden variable, or to a shared randomness between Alice and Bob. If a box violates this condition, it is explicitly called nonlocal. However, the study of nonlocal boxes often encompasses both local and nonlocal boxes.

The set of nonlocal boxes most commonly studied are the so-called non-signalling boxes,[32] for which neither Alice nor Bob can signal their choice of input to the other. Physically, this is a reasonable restriction: setting the input is physically analogous to making a measurement, which should effectively provide a result immediately. Since there may be a large spatial separation between the parties, signalling to Bob would potentially require considerable time to elapse between measurement and result, which is a physically unrealistic scenario.

The non-signalling requirement imposes further conditions on the joint probability, in that the probability of a particular output a or b should depend only on its associated input. This allows for the notion of a reduced or marginal probability on both Alice and Bob's measurements, and is formalised by the conditions:

${\displaystyle \sum _{b}P\left({a,b}{|}{A,B}\right)=\sum _{b}P\left({a,b}{|}{A,B'}\right)\equiv P\left({a}{|}{A}\right)\quad \forall {a,A,B,B'}}$

and

${\displaystyle \sum _{a}P\left({a,b}{|}{A,B}\right)=\sum _{a}P\left({a,b}{|}{A',B}\right)\equiv P\left({b}{|}{B}\right)\quad \forall {b,B,A,A'}}$

The constraints above are all linear, and so define a polytope representing the set of all non-signalling boxes with a given number of inputs and outputs. Moreover, the polytope is convex because any two boxes that exist in the polytope can be mixed (as above, according to some variable ${\displaystyle \lambda }$ with probabilities ${\displaystyle p(\lambda )}$) to produce another box that also exists within the polytope.

Local boxes are clearly non-signalling, however nonlocal boxes may or may not be non-signalling. Since this polytope contains all possible non-signalling boxes of a given number of inputs and outputs, it has as subsets both local boxes and those boxes which can achieve Tsirelson's bound in accord with quantum mechanical correlations. Indeed, the set of local boxes form a convex sub-polytope of the non-signalling polytope.

Popescu and Rohrlich's maximum algebraic violation of the CHSH inequality can be reached by a non-signalling box, referred to as a standard PR box after these authors, with joint probability given by:

${\displaystyle P\left({a,b}{|}{A,B}\right)={\begin{cases}{\frac {1}{2}},&{\mbox{if }}a\oplus b=AB\\0,&{\mbox{otherwise}}\end{cases}}}$

where ${\displaystyle \oplus }$ denotes addition modulo two.[33]

Various attempts have been made to argue why Nature does not (or should not) allow for stronger nonlocality than quantum theory is already known to permit. For example, it was found in the late 2000's that quantum mechanics cannot be more nonlocal without violating the Heisenberg uncertainty principle.[34][35] Strikingly, it was also discovered that if PR boxes did exist, any distributed computation could be performed with only one bit of communication.[36] An even stronger result is that for any nonlocal box theory which violates Tsirelson's bound, there cannot be a sensible measure of mutual information between pairs of systems.[37] This suggests a deep link between nonlocality and the information-theoretic properties of quantum mechanics. Nevertheless, the PR-box is ruled out by a plausible postulate of information theory.[38]

Non-signaling adversaries have recently been considered in quantum cryptography.[39] Such an adversary is constrained only by the non-signaling principle, and so may potentially be more powerful than a quantum adversary.

Blasiak's model

Similarly to de Broglie–Bohm pilot wave theory, Blasiak's model stipulates in the ontology a particle and a pilot wave, and the pilot wave ensures predictions indistinguishable from the quantum case.[6] The main distinction is wave function collapse. De Broglie–Bohm theory avoids collapse by including the whole universe (with all particle detectors, other devices, observers etc.) into the system. Blasiak's model describes a single particle in a quantum circuit (called "interferometric circuit") that contains devices such as phase shifters, beam splitters and particle detectors. Usually, a detector causes collapse (non-local, discontinuous change) of a wave function. But Blasiak's model treats detection without violating the locality principle, via the following ideas.

The wave function consists of fragments. Each fragment emerges from a detection, and propagates from the point of detection, gradually crowding out older fragments. The particle moves inside the expanding region occupied by the most recent fragment. Thus, obsolete fragments are harmless, they never pilot the particle. Gradual elimination of older fragments is implemented via the third ontological component, a field that carries information on the time of the most recent detection in the causal past of a given space-time point.

No information can travel faster-than-light

Nonlocality does not mean that information can travel faster-than-light. Indeed, quantum field theory preserves causality, meaning that no influence can be projected between two points faster than the speed-of-light.

This can be shown by noting that the commutator of two spacelike local quantum operators is always zero (or anti-commutator for fermionic operators).[40]

References

1. ^ Hensen, B, et al. (October 2015). "Loophole-free Bell inequality violation using electron spins separated by 1.3 kilometres". Nature. 526 (7575): 682–686. arXiv:1508.05949. Bibcode:2015Natur.526..682H. doi:10.1038/nature15759. PMID 26503041.
2. ^ a b Aspect, Alain; Dalibard, Jean; Roger, Gérard (December 1982). "Experimental Test of Bell's Inequalities Using Time- Varying Analyzers". Physical Review Letters. 49 (25): 1804–1807. Bibcode:1982PhRvL..49.1804A. doi:10.1103/PhysRevLett.49.1804.
3. ^ Rowe MA, et al. (February 2001). "Experimental violation of a Bell's Inequality with efficient detection". Nature. 409 (6822): 791–794. Bibcode:2001Natur.409..791K. doi:10.1038/35057215. PMID 11236986.
4. ^ Ghirardi, G.C.; Rimini, A.; Weber, T. (March 1980). "A general argument against superluminal transmission through the quantum mechanical measurement process". Lettere al Nuovo Cimento. 27 (10): 293–298. doi:10.1007/BF02817189.
5. ^ Staff (11 October 2018). "Public Release: 11-OCT-2018 - Where is it, the foundation of quantum reality?". EurekAlert!. Retrieved 13 October 2018.
6. ^ a b Blasiak, Pawel (13 July 2018). "Local model of a qudit: Single particle in optical circuits". Physical Review. 98 (012118) (1). doi:10.1103/PhysRevA.98.012118.
7. ^ a b Einstein, Albert; Podolsky, Boris; Rosen, Nathan (May 1935). "Can Quantum-Mechanical Description of Physical Reality Be Considered Complete?". Physical Review. 47 (10): 777–780. Bibcode:1935PhRv...47..777E. doi:10.1103/PhysRev.47.777.
8. ^ Einstein, Albert. "Letter to E. Schrödinger" [Letter]. Einstein Archives, ID: Call Number 22-47. Hebrew University of Jerusalem.
9. ^ Jevtic, S.; Rudolph, T (2015). "How Einstein and/or Schrödinger should have discovered Bell's theorem in 1936". Journal of the Optical Society of America B. 32 (4). pp. 50–55.
10. ^ a b c Nielsen, Michael A.; Chuang, Isaac L. (2000). Quantum Computation and Quantum Information. Cambridge University Press. pp. 112–113. ISBN 978-0-521-63503-5.
11. ^ Wiseman, H.M.; Jones, S.J.; Doherty, A.C. (April 2007). "Steering, Entanglement, Nonlocality, and the Einstein-Podolsky-Rosen Paradox". Physical Review Letters. 98.
12. ^ Bohr, N (July 1935). "Can Quantum-Mechanical Description of Physical Reality Be Considered Complete?". Physical Review. 48 (8): 696–702. Bibcode:1935PhRv...48..696B. doi:10.1103/PhysRev.48.696.
13. ^ Furry, W.H. (March 1936). "Remarks on Measurements in Quantum Theory". Physical Review. 49 (6): 476. Bibcode:1936PhRv...49..476F. doi:10.1103/PhysRev.49.476.
14. ^ von Neumann, J. (1932/1955). In Mathematische Grundlagen der Quantenmechanik, Springer, Berlin, translated into English by Beyer, R.T., Princeton University Press, Princeton, cited by Baggott, J. (2004) Beyond Measure: Modern physics, philosophy, and the meaning of quantum theory, Oxford University Press, Oxford, ISBN 0-19-852927-9, pages 144–145.
15. ^ Maudlin, Tim (2011). Quantum Non-Locality and Relativity : Metaphysical Intimations of Modern Physics (3rd ed.). John Wiley & Sons. p. 111. ISBN 9781444331264.
16. ^ Fine, Arthur (Winter 2017). "The Einstein-Podolsky-Rosen Argument in Quantum Theory". In Zalta, Edward N. (ed.). The Stanford Encyclopedia of Philosophy. Metaphysics Research Lab, Stanford University. Retrieved 6 December 2018.
17. ^ a b c d Bell, John (1964). "On the Einstein Podolsky Rosen paradox". Physics. 1 (3): 195–200. doi:10.1103/PhysicsPhysiqueFizika.1.195.
18. ^ Clauser, John F.; Horne, Michael A.; Shimony, Abner; Holt, Richard A. (October 1969). "Proposed Experiment to Test Local Hidden-Variable Theories". Physical Review Letters. 23 (15): 880–884. Bibcode:1969PhRvL..23..880C. doi:10.1103/PhysRevLett.23.880.
19. ^ Daniel M. Greenberger; Michael A. Horne; Anton Zeilinger (2007), Going beyond Bell's Theorem, arXiv:0712.0921, Bibcode:2007arXiv0712.0921G
20. ^ Hardy, Lucien (1993). "Nonlocality for two particles without inequalities for almost all entangled states". Physical Review Letters. 71 (11): 1665–1668. Bibcode:1993PhRvL..71.1665H. doi:10.1103/PhysRevLett.71.1665. PMID 10054467.
21. ^ Braun, D.; Choi, M.-S. (2008). "Hardy's test versus the Clauser-Horne-Shimony-Holt test of quantum nonlocality: Fundamental and practical aspects". Phys. Rev. A. 78 (3): 032114. arXiv:0808.0052. Bibcode:2008PhRvA..78c2114B. doi:10.1103/physreva.78.032114.
22. ^ Nikolić, Hrvoje (2007). "Quantum Mechanics: Myths and Facts". Foundations of Physics. 37 (11): 1563–1611. arXiv:quant-ph/0609163. Bibcode:2007FoPh...37.1563N. doi:10.1007/s10701-007-9176-y.
23. ^ a b Werner, R.F. (1989). "Quantum States with Einstein-Podolsky-Rosen correlations admitting a hidden-variable model". Physical Review A. 40 (8): 4277–4281. Bibcode:1989PhRvA..40.4277W. doi:10.1103/PhysRevA.40.4277. PMID 9902666.
24. ^ Bennett, C.H.; DiVincenzo, D.P.; Fuchs, C.A.; Mor, T.; Rains, E.; Shor, P.W.; Smolin, J.A.; Wootters, W.K. (1999). "Quantum nonlocality without entanglement". Physical Review A. 59 (2): 1070–1091. arXiv:quant-ph/9804053. Bibcode:1999PhRvA..59.1070B. doi:10.1103/PhysRevA.59.1070.
25. ^ Marius Junge; Carlos Palazuelos (2011). "Large violation of Bell inequalities with low entanglement". Communications in Mathematical Physics. 306 (3): 695–746. arXiv:1007.3043. Bibcode:2011CMaPh.306..695J. CiteSeerX 10.1.1.752.4896. doi:10.1007/s00220-011-1296-8.
26. ^ Thomas Vidick; Stephanie Wehner (2011). "More Non-locality with less Entanglement". Physical Review A. 83 (5): 052310. arXiv:1011.5206. Bibcode:2011PhRvA..83e2310V. doi:10.1103/PhysRevA.83.052310.
27. ^ Yeong-Cherng Liang; Tamas Vertesi; Nicolas Brunner (2010). "Semi-device-independent bounds on entanglement". Physical Review A. 83 (2): 022108. arXiv:1012.1513. Bibcode:2011PhRvA..83b2108L. doi:10.1103/PhysRevA.83.022108.
28. ^ Cirel'son, B. S. (1980). "Quantum generalizations of Bell's inequality". Letters in Mathematical Physics. 4 (2): 93–100. Bibcode:1980LMaPh...4...93C. doi:10.1007/BF00417500.
29. ^ Popescu, Sandu; Rohrlich, Daniel (1994). "Nonlocality as an axiom". Foundations of Physics. 24 (3): 379–385. Bibcode:1994FoPh...24..379P. CiteSeerX 10.1.1.508.4193. doi:10.1007/BF02058098.
30. ^ Rastall, Peter (1985). "Locality, Bell's theorem, and quantum mechanics". Foundations of Physics. 15 (9): 963–972. Bibcode:1985FoPh...15..963R. doi:10.1007/bf00739036.
31. ^ Khalfin, L.A.; Tsirelson, B.S. (1985). Lahti; et al. (eds.). Quantum and quasi-classical analogs of Bell inequalities. Symposium on the Foundations of Modern Physics. World Sci. Publ. pp. 441–460.
32. ^ a b c Barrett, J.; Linden, N.; Massar, S.; Pironio, S.; Popescu, S.; Roberts, D. (2005). "Non-local correlations as an information theoretic resource". Physical Review A. 71 (2): 022101. arXiv:quant-ph/0404097. Bibcode:2005PhRvA..71b2101B. doi:10.1103/PhysRevA.71.022101.
33. ^ Barrett, Jonathan; Pironio, Stefano (September 2005). "Popescu-Rohrlich Correlations as a Unit of Nonlocality". Physical Review Letters. 95 (14): 140401. arXiv:quant-ph/0506180. Bibcode:2005PhRvL..95n0401B. doi:10.1103/PhysRevLett.95.140401. PMID 16241631.
34. ^ Michael M. Wolf; David Perez-Garcia; Carlos Fernandez (2009). "Measurements Incompatible in Quantum Theory Cannot Be Measured Jointly in Any Other No-Signaling Theory". Physical Review Letters. 103 (23): 230402. arXiv:0905.2998. Bibcode:2009PhRvL.103w0402W. doi:10.1103/PhysRevLett.103.230402. PMID 20366131.
35. ^ Jonathan Oppenheim; Stephanie Wehner (2010). "The uncertainty principle determines the non-locality of quantum mechanics". Science. 330 (6007): 1072–1074. arXiv:1004.2507. Bibcode:2010Sci...330.1072O. doi:10.1126/science.1192065. PMID 21097930.
36. ^ van Dam, Wim (2005). "Implausible Consequences of Superstrong Nonlocality". arXiv:quant-ph/0501159.
37. ^ Pawlowski, M.; Paterek, T.; Kaszlikowski, D.; Scarani, V.; Winter, A.; Zukowski, M. (October 2009). "Information Causality as a Physical Principle". Nature. 461 (7267): 1101–1104. arXiv:0905.2292. Bibcode:2009Natur.461.1101P. doi:10.1038/nature08400. PMID 19847260.
38. ^ Pfister, Corsin; Wehner, Stephanie (2013). "If no information gain implies no disturbance, then any discrete physical theory is classical". Nature Communications. 4 (1851): 1851. arXiv:1210.0194. doi:10.1038/ncomms2821. PMID 23673636.
39. ^ Barrett, Jonathan; Hardy, Lucien; Kent, Adrian (2005). "No Signalling and Quantum Key Distribution". Physical Review Letters. 95 (1): 010503. arXiv:quant-ph/0405101. Bibcode:2005PhRvL..95a0503B. doi:10.1103/PhysRevLett.95.010503. PMID 16090597.
40. ^ Peskin, M. E., & Schroeder, D. V. (1995). An Introduction To Quantum Field Theory (Frontiers in Physics). Westview Press Incorporated. pp. 25-29


text:
# Flow types¶

Summer’s CompartmentalModel class offers a variety of intercompartmental flows that you can use to define the dynamics of your model. In this example we will cover:

First let’s define some utility functions to help with the example below.

[1]

import numpy as np
import matplotlib.pyplot as plt
from summer import CompartmentalModel

def build_model():
"""Returns a new SIR model"""
return CompartmentalModel(
times=[0, 20],
compartments=["S", "I", "R"],
infectious_compartments=["I"],
timestep=0.1,
)

def plot_compartments(model, times=[]):
"""Plot model compartment sizes over time"""
fig, ax = plt.subplots(1, 1, figsize=(12, 6), dpi=120)
for i in range(model.outputs.shape[1]):
ax.plot(model.times, model.outputs.T[i])

for t in times:
ax.axvline(x=t, color='k', linestyle='--', alpha=0.3)

ax.set_title("SIR Model Outputs")
ax.set_xlabel("Days")
ax.set_ylabel("Compartment size")
ax.set_ylim(bottom=0)
ax.legend(["S", "I", "R"])
start, end = ax.get_xlim()
ax.xaxis.set_ticks(np.arange(start + 1, end, 5))
plt.show()

## Transition flow¶

With a “fractional” transition flow, some proportion of the people in the source compartment transition from this compartment to the destination per time unit. In the example below, 10% of infected people recover per day.

[2]

model = build_model()
model.set_initial_population(distribution={"I": 1000})

# Add a recovery flow where 10% of the source recover per time unit.

model.run()
plot_compartments(model)

## Time varying parameters (transition flow)¶

The rate at which people transition can be set as a constant, or it can be defined as a function of time. This is the case of all of the flows: every parameter can be a constant or a function of time.

[3]

model = build_model()
model.set_initial_population(distribution={"S": 0, "I": 1000})

def recovery_rate(time):
"""
Returns the recovery rate for a given time.
People recover faster after day ten due to a magic drug.
"""
if time < 10:
return 0.1
else:
return 0.4

# Add a recovery flow where 10% of the source recover per time unit.

# Use Runge-Kutta 4 solver to better capture sharp discontinuity.
model.run(solver="rk4")
plot_compartments(model, times=[10])

## Infection density flow¶

This flow can be used to model infections using density-dependent disease transmission (as opposed to frequency dependent). This article may be helpful in understanding the difference between the two methods.

In unstratified models, the density-dependent infection flow rate (people infected per time unit) is calculated as:

# contact_rate: Rate at which effective contact happens between two individuals, i.e. contact that would result in transmission were it to occur between a susceptible and an infectious person
# num_source: Number of people in the (susceptible) source compartment
# num_infectious: Number of people infectious
force_of_infection = contact_rate * num_infectious
flow_rate = force_of_infection * num_source

[4]

model = build_model()
model.set_initial_population(distribution={"S": 990, "I": 10})

# Add a density dependent infection flow.

model.run()
plot_compartments(model)

## Infection frequency flow¶

This flow can be used to model infections using frequency-dependent disease transmission.

In unstratified models, the frequency-dependent infection flow rate (the number of people infected per time unit) is calculated as:

# contact_rate: Rate at which contact happens between people and results in a transmission
# num_source: Number of people in the (susceptible) source compartment
# num_infectious: Number of people infected
# num_pop: Total number of people in the population
force_of_infection = contact_rate * num_infectious / num_pop
flow_rate = force_of_infection * num_source

[5]

model = build_model()
model.set_initial_population(distribution={"S": 990, "I": 10})

# Add a frequency dependent infection flow.

model.run()
plot_compartments(model)

## Death flow¶

With a death flow, some percent of people in a user-selected source compartment die and leave the system every time unit.

[6]

model = build_model()
model.set_initial_population(distribution={"S": 1000, "I": 1000})

# 3% of the infected population die per day due to the infection.

# 1% of the susceptible population die per day due to tiger attacks.

model.run()
plot_compartments(model)

## Universal death flow¶

Adding “universal deaths” is a convenient way to set up a death flow for every compartment, which can account for non-disease mortality (heart disease and getting hit by a bus). This is functionally the same as manually adding a death flow for every compartment. You can adjust the universal death rate for particlar strata later during the stratification process (e.g. age-based mortality).

[7]

model = build_model()
model.set_initial_population(distribution={"S": 700, "I": 200, "R": 100})

# 2% of the population die per day for non-infection-related reasons.

model.run()
plot_compartments(model)

## Crude birth flow¶

Some percentage of the total population are born into the destination compartment every time unit.

[8]

model = build_model()
model.set_initial_population(distribution={"S": 700, "I": 600, "R": 500})

# 5% of the total population per day are born as susceptible.

model.run()
plot_compartments(model)

## Importation flow¶

An absolute number of people arrive in the destination per time unit. This can be used to model arrivals from outside of the modelled region.

[9]

model = build_model()
model.set_initial_population(distribution={"S": 700, "I": 600, "R": 500})

# 12 susceptible people arrive per year.

# 6 infected people arrive per year.

model.run()
plot_compartments(model)

## Replacement birth flow¶

Add a flow to replace the number of deaths into the destination compartment. This means the total population should be conserved over time.

[10]

model = build_model()
model.set_initial_population(distribution={"S": 650, "I": 600, "R": 0})

# 5% of the infected population die per year due to infection.

# The infected people who have died arrive back in the susceptible compartment.

model.run()
plot_compartments(model)

## Function flow¶

A function flow gives you more control over how a flow should work. This is when you need to include more complex behaviour in your model which cannot be expressed using the built-in flows above.

[11]

model = build_model()
model.set_initial_population(distribution={"S": 650, "I": 100, "R": 0})

def get_vaccination_flow_rate(flow, comp_names, comp_vals, flows, flow_rates, derived_values, time):
"""
Returns the flow-rate of susceptible people who get vaccinated and become recovered.

Args:
flow: The flow object being run
comp_names: List of compartment names (Compartment)
comp_vals: Array of compartment values at this timestep
flows: List of flow objects (used to calculate flow rates)
flow_rates: Calculated flow rate for each non-function flow at this timestep
time: Current timestep

Returns: The flow rate (float)
"""
if time < 5:
# Vaccinate 10 people per day until day 5
return 10
elif 5 < time < 15:
# Vaccinate 5% of the total population per day until day 15
return 0.05 * comp_vals.sum()
else:
# After day 15 stop vaccinations, because we ran out of money
return 0

# Use a custom function to model vaccinations

# Use Runge-Kutta 4 solver to better capture sharp discontinuity.
model.run(solver="rk4")
plot_compartments(model, times=[0, 20])

## Summary¶

That’s it for now, now you know how to use all the flow types available in summer to define the dynamics of your compartmental model. In future examples you will see how to use these flows in a stratified model.

A detailed API reference of the CompartmentalModel class can be found here

[ ]


text:
# Homework Help: Definite integral as Riemann sums

1. Nov 8, 2016

### terryds

1. The problem statement, all variables and given/known data

Determine $\int_{0}^{2}\sqrt{x}dx$ using left riemann sums

2. Relevant equations

$\int_{a}^{b}f(x)dx = \lim_{n\rightarrow \infty}\sum_{i=0}^{n-1}(\frac{b-a}{n})f(x_i)$

3. The attempt at a solution

$\frac{b-a}{n}=\frac{2-0}{n}=\frac{2}{n}$
$\int_{0}^{2}\sqrt{x}dx = \lim_{n\rightarrow \infty}\frac{2}{n}(0+ \frac{\sqrt{2}}{n}+\frac{\sqrt{4}}{n}+...) =\lim_{n\rightarrow \infty}\frac{2}{n} \frac{\sqrt{2}}{n}(\sqrt{0} + \sqrt{1}+\sqrt{2}+\sqrt{3}+...)$

2. Nov 8, 2016

### LCKurtz

I think you may want a square root on that $n$ I colored red. But to answer your question, that is not a trivial sum to calculate, and I wouldn't expect to see this problem in a typical calculus exercise set. See, for example,
http://math.stackexchange.com/questions/1241864/sum-of-square-roots-formula

3. Nov 8, 2016

### Staff: Mentor

The sums in the last two expressions above do not have an infinite number of terms. What's the last term in each sum?

4. Nov 9, 2016

### terryds

$\lim_{n\rightarrow \infty }\frac{2}{n}\sqrt{\frac{2}{n}}(\sqrt{0} + \sqrt{1} + \sqrt{2} + ... + \sqrt{\frac{2}{n}}(n-1)))$

Alright, I've fixed my mistakes. And, I'm still confused how to get the sum of that series

5. Nov 9, 2016

### Ray Vickson

You should go back and read post #2, which explains why you probably cannot sum the series, no matter how hard you try. Of course, you may be able to find good approximations to the sum, but that is not the same as finding an exact value.

6. Nov 10, 2016

### lurflurf

Doing the sum is overkill for finding the limit.
I think you have an error I think you should have
$$\int_0^2 \! \sqrt{n} \, \mathrm{d}x=\lim_{n\rightarrow\infty} {\left( \frac{n}{2} \right)}^{-3/2}\sum_{i=1}^n \sqrt{n}$$
Instead of finding the sum we will make a few observations that suffice
we can replace the sum in the limit by a simple expression
$$\sum_{i=1}^n \sqrt{n}\sim {C} {\sqrt{n}}^3$$
The exponent is the only one that allows the limit to converge to a nonzero value
we find C by computing the limit
$$C=\lim_{n\rightarrow\infty}\frac{{\sqrt{n}}}{{\sqrt{n+1}}^3-{\sqrt{n}}^3}$$
because we must have
$$\sum_{i=1}^{n+1} \sqrt{n}-\sum_{i=1}^n \sqrt{n}\sim {\sqrt{n}}$$


text:
63/145
\begin{frame}
\small

\begin{definitions}
\begin{itemize}
\item
term $t$ is \alert<1>{linear} is each variable in $\Var(t)$
occurs exactly once in $t$
\item<2->
rewrite rule $\ell \to r$ is \alert<2>{left-linear} if $\ell$ is linear
\item<3->
TRS is left-linear if all rewrite rules are left-linear
\item<4->
rewrite rule $\ell \to r$ is \alert<4>{right-linear} if $r$ is linear
\item<5->
rewrite rule $\ell \to r$ is \alert<5>{linear} if $\ell$ and $r$ are linear
\item<6->
TRS is (right-)linear if all rewrite rules are (right-)linear
\end{itemize}
\end{definitions}

\bigskip

\begin{examples}<7->
\begin{itemize}
\item<7->
$\m{g}(\alert<7>x) \to \m{f} (\alert<7>{x},\m{g}(\alert<7>{x}))$ \\[.5ex]
left-linear but not right-linear
\item<8->
$\m{f}(\alert<8>{x},\alert<8>{x}) \to \m{a}$ \\[.5ex]
right-linear but not left-linear
\end{itemize}
\end{examples}
\end{frame}


text:
# Finding range of p-values from linear regression model

A statistical relationship model has the following data:

$$\text{Sample size: }n=18$$ $$\text{Relationship: }Y_i = \alpha + \beta x_i +R_i, R_i \sim G(0,\sigma), i\in \{1,\dots,18\}, \text{ independent}$$ $$\text{Parameter estimates: } \hat{\alpha}=-7, \hat{\beta}=1.2, s_e = 12.36, \overline{x}=69.06, S_{xx}=1482$$

Given these data, I want to find an appropriate range for the p-value to be used to test that there is no relationship between $x$ and $Y$, that is that $H_0: \beta =0$ against the alternative, $H_a:\beta\ne 0$.

I can use tables or R to determine this range. But to determine the $t$ value I need to determine two imput values: a quantile $q$ and the degrees of freedom, which I think there are $n-1=17$.

How does one determine the parameter $q$ given the above data? Also, how can we construct 95% confidence and prediction intervals with this value of $t$? Unfortunately, I seem to lack this specific knowledge.

• Degrees of freedom for the t-statistic would be $n-2=16. \qquad$ – Michael Hardy Nov 28 '17 at 6:40

The formulas you seek can be found on Wikipedia.

The quantile will be $$\frac{\hat{\beta} - 0}{\operatorname{s.e.}(\hat{\beta})}$$ where $$\operatorname{s.e.}(\hat{\beta}) = \sqrt{\frac{\frac{1}{n-2} \sum_{i=1}^n \hat{e}_i^2}{\sum_{i=1}^n (x_i - \bar{x})^2}} \overset{?}{=} \frac{s_e}{S_{xx}}.$$ (I am not sure how your quantities are defined, so I am not sure if the last equality is correct. Here, $\hat{e}_i$ are the residuals.)

The degrees of freedom is actually $n - 2$ (the minus $2$ is due to the two parameters in your model: $\alpha$ and $\beta$).

Response to comment:

If your $q$ is correct, then you should do 2*(1 - pt(1439,16)) for the $p$-value of a two-sided $t$-test. pt() is the CDF of the $t$-distribution, so it give you the probability on the interval $(-\infty, 1439]$. Intuitively, the $p$-value is nearly zero since $1439$ is very far in the tails of the distribution.

Of course this is contingent on the computation for $q$ being correct, but I suspect it is not. I suspect the standard error should be $\frac{12.36}{\sqrt{1482}}$ rather than $\frac{12.36}{1482}$. Only you can check this, since I do not know how your $S_{xx}$ is defined.

• So I found $s.e.(\beta)=0.00834$ and $q=1439$. Now $pt(1439, 16)=1$ in R. Can you please point out what is it that I'm doing wrong? – sequence Nov 28 '17 at 7:35
• @sequence See my update. – angryavian Nov 28 '17 at 7:44
• Thanks. I had made a typo. Now with $s.e.(\hat{\beta})=\frac{12.36}{\sqrt{1482}}\approx 0.3211$ I get $q=3.74$ and the p-value is approximately $0.00179$. But how does one determine the range for the p-value if this is just one value? – sequence Nov 28 '17 at 7:53
• @sequence This terminology "determine the range for the $p$-value" is unfamiliar to me. You pick a level, say $\alpha=5\%$, before you do the test, and you "reject the null hypothesis at level $\alpha$" if the $p$-value that you obtain is $<\alpha$. – angryavian Nov 28 '17 at 8:00
• It is mentioned that somehow it is possible to find the range using the t-table, but I'm not sure how. @angryavian – sequence Nov 28 '17 at 8:15


text:
# What is it called when you type math directly into a property?

In After Effects we call it expressions or action scripting. In c4d we use Xpresso or in the old days C.O.F.F.E.E.

What is it commonly referred to in blender when you just want to do something similar to time * 50 in a property without using drivers or invoking all kinds of custom scripting?

I tried searching for expressions and scripting but all I end up with is how to write add-ons and script in python.

Despite saying it's not what you want, what you've described is a driver. It might sometimes be called a 'Scripted Expression' (and the Blender Manual now refers to it simply as an 'Expression'), but it's still just a type of driver.

Type #frame * 10 into a property field, e.g. the 'X' location of an object, and press Enter and the property will turn purple, indicating the expression has automatically been turned into a driver. This driver can then be tweaked either by clicking on the property again or by looking in the 'Drivers Editor'.

The types of commands that can be typed into property fields are called 'Simple Expressions'.

An example of the keywords you can type into a property from the Blender Manual:

Globals

frame

Constants

pi, True, False

Operators

+, -, *, /, ==, !=, <, <=, >, >=, and, or, not, conditional operator/ ternary if

Functions

min, max, radians, degrees, abs, fabs, floor, ceil, trunc, int, sin, cos, tan, asin, acos, atan, atan2, exp, log, sqrt, pow, fmod

Note: You need to have a # symbol in front of the expression, e.g. #frame * 2. In the case of 'Constants', 'Operators' and 'Functions' (but not frame), if you omit the # Blender will simply change the property to be the result of the expression, but it won't be driven by it.

• thank you. that was what I was looking for. I thought it was called a "driver" but all the searching I did brought up things that use other objects as drivers and not just math. Thank you. – Chris Jul 1 '20 at 16:00
• Ray Note in link also answers blender.stackexchange.com/questions/134270/… since self is not in list. On your note, can type cos(pi) directly into a field and it will be the result. However cannot do same with frame as it doesn't appear to be in the "UI namespace" only the driver namespace. – batFINGER Jul 1 '20 at 16:58