text:
# Instrumental magnitude

Instrumental magnitude refers to an uncalibrated apparent magnitude, and, like its counterpart, it refers to the brightness of an astronomical object seen from an observer on Earth, but unlike its counterpart, it is only useful in relative comparisons to other astronomical objects in the same image (assuming the photometric calibration does not spatially vary across the image; in the case of images from the Palomar Transient Factory, the absolute photometric calibration involves a zero point that varies over the image by up to 0.16 magnitudes to make a required illumination correction[1]). Instrumental magnitude is defined in various ways, and so when working with instrumental magnitudes, it is important to know how they are defined. The most basic definition of instrumental magnitude, ${\displaystyle m}$, is given by

${\displaystyle m=-2.5\log _{10}(f)}$

where ${\displaystyle f}$ is the intensity of the source object in known physical units. For example, in the paper by Mighell,[2] it was assumed that the data are in units of electron number (generated within pixels of a charge-coupled device). The physical units of the source intensity are thus part of the definition required for any instrumental magnitudes that are employed. The factor of 2.5 in the above formula originates from the established fact that the human eye can only clearly distinguish the brightness of two objects if one is at least approximately 2.5 times brighter than the other.[3] The instrumental magnitude is defined such that two objects with a brightness ratio of exactly 100 will differ by precisely 5 magnitudes, and this is based on Pogson's system of defining each successive magnitude as being fainter by ${\displaystyle 100^{1/5}}$. We can now relate this to the base-10 logarithmic function and the leading coefficient in the above formula:

${\displaystyle 100^{1/5}=(10^{2})^{1/5}=10^{2/5}=10^{0.4}=2.51188643\cdots }$

The approximate value of 2.5 is used as a convenience, its negative sign assures that brighter objects will have smaller and possibly negative values, and tabulated values of base-10 logarithms were available more than three centuries before the advent of computers and calculators.

## References

1. ^ Ofek, E. O.; Laher, R.; Law, N.; et al. (2012). "The Palomar Transient Factory Photometric Calibration". Publications of the Astronomical Society of the Pacific. 124: 62–73. Bibcode:2012PASP..124...62O. arXiv:. doi:10.1086/664065.
2. ^ Mighell, Kenneth J. (1999). "Algorithms for CCD Stellar Photometry". ASP Conference Series. 172: 317–328.
3. ^ Harwit, Martin (1982), Astrophysical Concepts, Concepts, pp. 508–9, ISBN 0-910533-00-8


text:
# Qiskit textbook - exercise 2.2 - why doesn't the correct answer give the same statevector?

In the Qiskit textbook, I'm stuck on one of the exercises in section 2.2. The question is:

Write the state: as two separate qubits.

The answer has already been covered in this question here, and is defined as:

This makes sense to me - we're basically factoring out the first qubit. However, for my own benefit, I tried multiplying out the vectors and I get different results:

Using the original form:

Using the answer supplied:

Why don't these give the same values?

n.b. Apologies for the use of images - I only had MS Word at my disposal and couldn't find an easy way to export the equations bar screen-shotting.

• You do not need additional software to write mathematics on this site, for a quick overview of how to do this please see this page – Rammus Feb 21 at 14:38
• Thanks - I already had the equations in Word, so I was trying (unsuccessfully) to convert them without downloading any other tools. Next time, I'll start by writing them directly in the question. – David Fulton Feb 21 at 16:43

In your answer you are treating $$|xy\rangle$$ as a direct sum of vectors $$|x\rangle$$ and $$|y\rangle$$. However, $$|xy\rangle = |x\rangle \otimes |y\rangle$$ is actually shorthand for the tensor (Kronecker) product of $$|x\rangle$$ and $$|y\rangle$$ (see wiki for more details on the Kronecker product).
In particular if $$|x\rangle = \begin{pmatrix} a \\ b\end{pmatrix}$$ and $$|y\rangle = \begin{pmatrix} c \\ d \end{pmatrix}$$ then $$|xy\rangle = |x\rangle\otimes |y\rangle = \begin{pmatrix} ac \\ ad \\ bc \\ bd \end{pmatrix}.$$
• Not sure what you mean by both. $$|00\rangle = \begin{pmatrix} 1 \\ 0 \end{pmatrix} \otimes \begin{pmatrix} 1 \\ 0 \end{pmatrix} = \begin{pmatrix} 1 \\ 0 \\ 0 \\ 0 \end{pmatrix}$$ and $$|01\rangle = \begin{pmatrix} 1 \\ 0 \end{pmatrix} \otimes \begin{pmatrix} 0 \\ 1 \end{pmatrix} = \begin{pmatrix} 0 \\ 1 \\ 0 \\ 0 \end{pmatrix}$$ – Rammus Feb 21 at 16:57
• By "both", I meant the vector of the factorised answer and the vector from the original question. I think both should have come out as $\frac{1}{\sqrt(2)} \begin {pmatrix} 1 \\ i \\ 0 \\ 0 \end{pmatrix}$ – David Fulton Feb 21 at 17:04

format: plain


text:
수식부호
문제
L-b 색칠한 부분의 넓이를 구해 보세요. (원주율: 3) 9 cm $8\right)-$ $60,75$ $\right)cm^{2}$ 1. $9cmr$ $\times 4\dfrac {5} {5}$ $\dfrac {4} {2}$ $.5$ $\dfrac {\dfrac {2} {8}0} {2^{3}.25}$ $4\left(\bar{A}$ $16cm$ 2. $\right)cm^{2}$ $8cm$ -2 cm 3. $\right)cm^{2}$ $20cm$ $10cm$ $cm^{2}$ 4. $10cm$ 5. $20cm$ $\right)cm^{2}$ $16cm$ 8 cm $\right)cm^{2}$ 6.
초등학교
초3 수학
검색 수: 319
풀이
콴다 선생님 - 이랑
학생
감사합니다!
아직도 궁금하다면?
콴다 선생님께 질문하기


text:
# Factoring cubic Polynomials

Any polynomial with degree three is called a polynomial of degree three or generally as cubic polynomial.
A cubic polynomial in one variable can be generally written as
$f(x) = ax^{3}+bx^{2}+cx+d$ where x is the variable and a, b, c and d are the constants.

Any cubic polynomial in the form $x^ {3} +y^ {3}$ is called perfect cubic polynomial.
It has a special formula
$x^ {3} +y^ {3} =(x+y) (x^ {2}-xy+y^{2})$
$x^ {3} - y^ {3}=(x-y) (x^ {2} +xy+y^ {2})$

Factoring is the process by which a polynomial can be written as the product of two or more simpler polynomialThe first thing is to check if there exist a greatest common factor (GCF), generally called, common factor, in the polynomial.
For example $21y^{2} – 14y^{3}$
The following steps has to be followed.
• Identify each of the terms and its factors in the polynomial
Here there are two terms $21y^{2}$and $14y^{3}$
$21y^{2}=1*3*5*y*y$
$14y^{3}= 1*3*7*y*y*y$
• Find the GCF
Here GCF=$1*7*y*y=7y^{2}$
• Write the GCF outside the parenthesis
Here $7y^{2}( )$
• Divide each term by the GCD
Here, $\frac{21y^{2}}{7y^{2}}=3$ and $\frac{14y^{3}}{7y^{2}}=2y$
• Write then inside the parentheses
$7y^{2}(3+2y)$
So, $21y^{2} – 14y^{3} = 7y^{2}(3+2y)$

Let consider another example: $y(2x^{2}+1)-5(2x^{2}+1)$

This follows the same steps.
• Identify each of the terms and its factors in the polynomial
In this problem, there are only two terms $y (2x^{2}+1)$ and $5(2x^{2}+1)$
$y (2x^{2}+1)= y*(2x^{2}+1)$ and $5(2x^{2}+1)= 5*(2x^{2}+1)$
• Find the common factor
It can be seen that the common factor here is a binomial, that is $(2x^{2}+1)$
• Write the GCF outside the parenthesis
$(2x^{2}+1)( ) • Divide each term by the GCD Here,$\frac{ y(2x^{2}+1)}{ (2x^{2}+1)}=y$and$\frac{ 5(2x^{2}+1)}{ (2x^{2}+1)}=5$• Write then inside the parentheses$(2x^{2}+1)( y+5)$So,$y(2x+1)-5(2x+1) = (2x^{2}+1)(y-5)$A polynomial can be called prime if it cannot be factored into product of polynomials other than 1 and the polynomial itself. For example$x^{3} – 4w^{2}\$


text:
• 13
• 18
• 19
• 27
• 10

# Puzzling Performance Problem

This topic is 4577 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Basically, I load a map into my engine (DX8 in VB, running at 800x600) which just has a brick wall in it, and I get around 40FPS, which is enough for me. But when I add this tree, it drops to 6FPS. Even if I run it at 1152x864, I still get 6FPS. I know it's not because of the trees polycount (which is 10218), because I can load 8 of them into my old, unfinished engine (DX7RM in VB) and get 30FPS: I'm using hardware vertex processing, and when I switch it to software vertex processing, the 6FPS changes to 18FPS. Disabling the texture of the tree does not affect the FPS. I doubt my specs are causing it (I can play games such as HL2 or GTA:SA fine). So does anyone have any ideas what's going on?

##### Share on other sites

Are you using VertexBuffers? What flags do you set when creating the buffers, and when locking them? Do you lock them each frame? Are you maybe creating them each frame?

Is VSync on?

Are you using the debug runtimes (I'm not sure this is available for visual basic, but if it is, are you?)?

##### Share on other sites
Quote:
 Original post by sirobHow are you loading the model? is it an .x File loaded with D3DXMESH?

Yup, .x with D3DXMESH.
Quote:
 Original post by sirobAre you using VertexBuffers? What flags do you set when creating the buffers, and when locking them? Do you lock them each frame? Are you maybe creating them each frame?Is VSync on?Are you using the debug runtimes (I'm not sure this is available for visual basic, but if it is, are you?)?

Hmm.. I'm emabarrssed to say this, but I can't answer any of those questions, because I have no idea.

##### Share on other sites
1. Can you show us some code? (inside source tags, check GDNet Forums FAQ)
2. Make sure you're not updating the framerate display in the window caption, because that's very slow.

##### Share on other sites
What code would you like to see?
Here's the rendering code, it's a little weird though.
D3DDevice.Clear 0, ByVal 0, D3DCLEAR_TARGET, D3DColorXRGB(AmbientLight, AmbientLight, AmbientLight), 1#, 0D3DDevice.Clear 0, ByVal 0, D3DCLEAR_ZBUFFER, 0, 1#, 0ColCheckD3DDevice.BeginSceneFor a = 0 To ObjCount - 1    If ObjNotDraw(a) = 0 Then    D3DXMatrixTranslation MeshMatrix(a), ObjPos(a).X, ObjPos(a).Y, ObjPos(a).Z    D3DDevice.SetTransform D3DTS_WORLD, MeshMatrix(a)    D3DDevice.SetTexture 0, ObjTexture(a)        ObjMesh(a).DrawSubset 0        If nMaterials(a) > 1 Then            For b = 0 To nMaterials(a) - 1                D3DDevice.SetMaterial MeshMaterials(a, b)                D3DDevice.SetTexture 0, MeshTextures(a, b)                ObjMesh(a).DrawSubset b            Next b        End If    End IfNext aD3DDevice.SetTransform D3DTS_WORLD, matWorldD3DDevice.SetTexture 0, FloorTexD3DDevice.DrawPrimitiveUP D3DPT_TRIANGLELIST, 2, Floor(0), Len(Floor(0))D3DDevice.SetTexture 0, WallsTexD3DDevice.DrawPrimitiveUP D3DPT_TRIANGLELIST, 8, Walls(0), Len(Walls(0))D3DDevice.EndSceneD3DDevice.Present ByVal 0, ByVal 0, 0, ByVal 0

I've tried commenting out things such as the collision checking (ColCheck), textures, etc. to see how they affect perfomance, and they tend to make little or no difference.

##### Share on other sites
Have you checked debug output to make sure there are no errors? I use DX8 in VB also and its very helpful. You have to install the newest SDK (dx 9.0) and then change it to debug output in the control panel, and use a debug viewer... but if you're doing something really ridiculous it will tell you!

##### Share on other sites
I'm afraid to get the SDK. In order to download it, I have to first go through the Windows Validation thing, and because my computer came with Windows pre-loaded, I think it might fail. I'm afraid if it fails, they would stop Windows from functioning.

##### Share on other sites
Windows validation shouldn't fail on a pre-loaded machine unless it was pre-loaded with an illegal or shared copy which probably would have failed when you first activated windows.

Outside of that if the place you bought the computer from is illegally pre-loading stuff then you can go and bitch at them until they give you a real copy. If it was you that was borrowing a friends copy to just check out and evaluate you can always buy a copy. Trust me when you start writing your own games or apps you will want to support other developers by buying all the software you run. It makes it a lot easier to bitch about people copying your stuff :)

##### Share on other sites
I'd rather not take the risk.

Any other suggestions to as why my game is running so slow, and perhaps how I could fix it?

##### Share on other sites
Quote:
 Original post by luke88I'd rather not take the risk.

There is no risk.

If you have an authentic version of Windows with a COA seal than you own a legitimate copy of Windows and there is absolutely no reason to fail validation.

If you have a stolen copy of Windows and/or do not have a COA seal than the validation would fail and you would be denied the download.

You shouldn't be running an illegal copy of Windows anyways so you should just go through the validation, as that will tell you if you have a stolen copy or not. Although you most likely already know the answer to that.


text:
### 2.41. types.dt_lib_collect_params_rule_t

dt_type

A single rule for filtering a collection

#### 2.41.1. types.dt_lib_collect_params_rule_t.mode

types.dt_lib_collect_mode_t

How this rule is applied after the previous one. Unused for the first rule

 Attributes: write

#### 2.41.2. types.dt_lib_collect_params_rule_t.data

string

The text segment of the rule. Exact content depends on the type of rule

 Attributes: write

#### 2.41.3. types.dt_lib_collect_params_rule_t.item

types.dt_collection_properties_t

The item on which this rule filter. i.e the type of the rule

 Attributes: write


text:
is there any relationship between the eigenvector of sum(AA'+BB') and sum(A'A+B'B) ? - MathOverflow most recent 30 from http://mathoverflow.net 2013-05-20T18:00:57Z http://mathoverflow.net/feeds/question/116856 http://www.creativecommons.org/licenses/by-nc/2.5/rdf http://mathoverflow.net/questions/116856/is-there-any-relationship-between-the-eigenvector-of-sumaabb-and-sumaabb is there any relationship between the eigenvector of sum(AA'+BB') and sum(A'A+B'B) ? David liu 2012-12-20T11:57:50Z 2012-12-21T04:53:32Z
is there any relationship between the eigenvector of sum(AA'+BB') and sum(A'A+B'B) ?

thanks a lot!
 http://mathoverflow.net/questions/116856/is-there-any-relationship-between-the-eigenvector-of-sumaabb-and-sumaabb/116873#116873 Answer by Steven Landsburg for is there any relationship between the eigenvector of sum(AA'+BB') and sum(A'A+B'B) ? Steven Landsburg 2012-12-20T15:37:50Z 2012-12-20T17:53:59Z
Assuming that \$sum(AA'+BB')\$ means \$AA'+BB'\$ and that \$A'\$ means the transpose of \$A\$:

Let \$x\$ and \$y\$ be arbitrary complex numbers. Then the matrices \$X=\pmatrix{0&1\cr 1&x\cr}\$ and \$Y=\pmatrix{0&1\cr1&y\cr}\$ have arbitrary eigenvectors. But in general, the equaions \$\$\matrix{AA'+BB'=X&A'A+B'B==Y}\$\$ are solvable for \$A,B\$. So the answer to your question is no.

Edit: As Terry Tao points out in comments, this system of equations is clearly not solvable (just take traces). So this is not an answer to your question.
 http://mathoverflow.net/questions/116856/is-there-any-relationship-between-the-eigenvector-of-sumaabb-and-sumaabb/116892#116892 Answer by Steven Landsburg for is there any relationship between the eigenvector of sum(AA'+BB') and sum(A'A+B'B) ? Steven Landsburg 2012-12-20T18:59:11Z 2012-12-20T20:10:10Z
By way of penance for my earlier "answer":

Take \$A=\pmatrix{1&0\cr x&0\cr}\$ and \$B=\pmatrix{1&y\cr 0&0\cr}\$.

Then the eigenvectors of \$M=AA'+BB'\$ and \$N=A'A+B'B\$ are in general different. As \$x\$ goes to 0, the eigenvectors of \$M\$ go off to zero and infinity while the eigenvectors of \$N\$ can be anything; as \$y\$ goes to 0, the eigenvectors of \$N\$ go off to zero and infinity while the eigenvectors of \$M\$ can be anything.
 http://mathoverflow.net/questions/116856/is-there-any-relationship-between-the-eigenvector-of-sumaabb-and-sumaabb/116951#116951 Answer by David liu for is there any relationship between the eigenvector of sum(AA'+BB') and sum(A'A+B'B) ? David liu 2012-12-21T04:44:49Z 2012-12-21T04:53:32Z
SORRY FOR come back later....

A is real matrix. sum(AA′+BB′) means AA′+BB′ and that A′ means the transpose of A.

thanks


text:
Vol. 15, No. 9, 2021

 Recent Issues
 The Journal About the Journal Editorial Board Editors’ Interests Subscriptions Submission Guidelines Submission Form Policies for Authors Ethics Statement ISSN: 1944-7833 (e-only) ISSN: 1937-0652 (print) Author Index To Appear Other MSP Journals
The Hasse principle for diagonal forms restricted to lower-degree hypersurfaces

Julia Brandes and Scott T. Parsell

Vol. 15 (2021), No. 9, 2289–2314
Abstract

We establish the analytic Hasse principle for Diophantine systems consisting of one diagonal form of degree $k$ and one general form of degree $d$, where $d$ is smaller than $k$. By employing a hybrid method that combines ideas from the study of general forms with techniques adapted to the diagonal case, we are able to obtain bounds that grow exponentially in $d$ but only quadratically in $k$, reflecting the growth rates typically obtained for both problems separately. We also discuss some of the most interesting generalisations of our approach.

However, your active subscription may be available on Project Euclid at
https://projecteuclid.org/ant

We have not been able to recognize your IP address 44.192.94.86 as that of a subscriber to this journal.
Online access to the content of recent issues is by subscription, or purchase of single articles.

or by using our contact form.


text:
# Find the total distance taken by the train.

[ A train starting from rest accelerate at the rate of 6m/s² for 20 seconds to attain a constant speed and it traveled for another 20 seconds and decelerate at the rate of 3m/s² for 20 seconds. Calculate the total distance (in kilometer) traveled by the train.
That's the question. I found it confusing when I was given the deceleration value.

Related Introductory Physics Homework Help News on Phys.org
SteamKing
Staff Emeritus
Homework Helper
[ A train starting from rest accelerate at the rate of 6m/s² for 20 seconds to attain a constant speed and it traveled for another 20 seconds and decelerate at the rate of 3m/s² for 20 seconds. Calculate the total distance (in kilometer) traveled by the train.
That's the question. I found it confusing when I was given the deceleration value.
Why? What's confusing about the deceleration of the train?

The train starts from rest and accelerates to a constant speed. The train travels at this constant speed for a certain time interval. The train then slows down for another time period.

Apply the SUVAT equations for each type of motion and add up the distances traveled.

andrevdh
Homework Helper
In both time intervals the speed of the train is changing.
In the first 20 s it is increasing.
In the next 20 s it is decreasing.
You can use the constant acceleration equations to calculate this.
How would you change the equations to calculate for the deceleration?

Chestermiller
Mentor
In both time intervals the speed of the train is changing.
In the first 20 s it is increasing.
In the next 20 s it is decreasing.
You can use the constant acceleration equations to calculate this.
How would you change the equations to calculate for the deceleration?
Try doing the problem in 3 parts. Part 1: What is the distance and velocity after accelerating at 6 m/s^2 for 20 seconds? Part 2: What is the distance after traveling at the constant velocity from Part 1 for an additional 20 seconds? Part 3: What is the additional distance and the final velocity after accelerating -3 m/s^2 for an additional 20 seconds?

Chet


text:
# Sample Mean expressed using Standard Normal Distribution

Let $$\bar{X}_n = X_1 + \dots X_n$$ where $$X_i \sim N(0,1)$$. We can easily verify that $$\bar{X}_n \sim N(0, 1/n)$$.

Thus $$\text{Var}(\bar{X}_n) = 1/n$$.

Let the density of $$X \sim N(0,1)$$ be denoted $$\phi(x) = \frac{1}{\sqrt{2 \pi}} e^{-\frac{x^2}{2}}$$.

Apparently we can write express $$\bar{X}_n = \frac{1}{\sqrt{n}} Z$$ where $$Z \sim N(0,1)$$ is the standard normal distribution.

My attempt so far is to note that $$\phi(\bar{x}_n) = \frac{1}{\sqrt{2 \pi} \frac{1}{\sqrt{n}}} e^{-\frac{x^2}{2 \frac{1}{n}}}$$

We can then define $$Z=\frac{\bar{X}_n - \mu}{\sigma} = \frac{\bar{X}_n}{\frac{1}{\sqrt{n}}}$$ as usual. Then be substiution we obtain:

$$\phi(\bar{x}_n) = \frac{1}{\frac{1}{\sqrt{n}}} \phi(z) = \sqrt{n} \phi(z)$$

Why do I keep getting the factor of $$\sqrt{n}$$ on the numerator rather than the denominator?

Thanks

You denote the prob. density by $$\phi(x)$$, I prefer $$f_X(x)$$.
If you like to rewrite this in terms of a new random variable $$z$$ you have to use a transformation, i.e. $$f_X(x) = f_Y(y) \left| \frac{dx}{dy}\right|$$ This is valid for continuous random variables, not for discrete random variables.
You have several errors caused by abuse of notations. First, let's define sample mean correctly: $$\bar{X_n}=\frac{1}{n}\sum_{i=1}^n X_i$$ Variance and mean are correct. The density of $$\bar{X_n}$$ can be correctly written as $$p_{\bar{X_n}}(x)$$ (or $$\phi_{\bar{X_n}}(x)$$ if you want, but I'll reserve $$\phi$$ for standard normal distribution). Your notation uses $$\phi(\bar{x_n})$$, as if you replace $$x$$ by $$\bar{x_n}$$ in the definition of $$\phi(x)$$. But, if we replace $$\phi(\bar{x_n})$$ by $$p_{\bar{X_n}}(x)$$, your density function for $$\bar{X_n}$$is correct, i.e. $$p_{\bar{X_n}}(x)=\frac{\sqrt{n}}{\sqrt{2\pi}}e^{-\frac{nx^2}{2}}$$ This can be written in terms of $$\phi(x)$$: $$p_{\bar{X_n}}(x)=\sqrt{n}(\sqrt{2\pi})^{n-1}\left(\frac{1}{\sqrt{2\pi}}e^{-\frac{x^2}{2}}\right)^n=\sqrt{n}(2\pi)^{(n-1)/2}\phi(x)^n$$
Another comment on how you're trying to relate the two: $$\sqrt{n}\phi(z)$$ is not equal to $$\phi(\bar{x_n})$$; first of all the variables are different, and if they are PDFs, then their integral should be $$1$$, but due to $$\sqrt{n}$$ one of them is not.
• Thanks. I follow your result that the x pdf can be written in terms of $\phi(x)^n$ but how does this show $\bqr{X}_n = n^{-1/2} Z$? See second to last line of page 1 in these notes for the claim: www.stat.cmu.edu/~larry/=stat705/Lecture2.pdf – user11128 Feb 24 '19 at 10:53
• This doesn't show $\bar{X_n}=\frac{1}{\sqrt{n}}Z$, but I tried to answer your title question. For this one, in the notes, $\bar{X_n}$ is defined that way via $\overset{d}=$ operator. So, it's basically saying that if $\bar{X_n}$ is Normal with $(0,1/n)$, then a standard normal RV can be defined such that $\bar{X_n}=\frac{1}{\sqrt{n}}Z$. – gunes Feb 24 '19 at 11:10
• Yes, and it also applies the fact that normal RVs are still normal under linear transformation. Other RVs may not satisfy this property. For example, if $X$ is Bernoulli, $2X$ is not Bernoulli. – gunes Feb 24 '19 at 11:16


text:
# All innovators - HELP!

Dr.Brain
All innovators --- HELP!

I have to think of some drawing/painting resembling the TOPIC "NIX PERIPHERA" which means "No Boundaries"

"NIX PERIPHERA" is the theme for our annual cultural fest in my tech-skool , and I have to think of some innovatory ideas regarding the paintings that we can make resembling the topic , also please tell ideas about structures that we can make which resemble the given topic in a way (like a 6" tall structure of Bird with open wings---> resembling no boundaries...blah blah) ...

ANything scientific/cool/wierd , anything that you can think of ...anythinggg..

BJ

zoobyshoe
An extreme closeup of Charles Manson's face would vividly illustrate the concept of "No Boundaries," I think.

Townsend
zoobyshoe said:
An extreme closeup of Charles Manson's face would vividly illustrate the concept of "No Boundaries," I think.

That's brilliant, I never would have thought of that.

Townsend
How about something to do with the tower of babel?

Staff Emeritus
Gold Member
$$(-\infty,\infty)$$

mattmns
Math Is Hard said:
$$(-\infty,\infty)$$
pfff!

This is more like it $$[-\infty, \infty ]$$

Knavish
But that makes no sense. :tongue: Besides, it adds a boundary, which isn't what we want.

mattmns
True, they both have boundaries, but at least mine includes infinity :tongue2:

Last edited:
Townsend
mattmns said:
True, they both have boundaries, but at least mine includes infinity :tongue2:

Really? So what then is $$[-\infty, \infty ] - (-\infty,\infty)$$ = ?

mattmns
I am not sure about the definition of infinity, but I would guess that the subtraction would be $$\{-\infty, \infty\}$$

Townsend
mattmns said:
I am not sure about the definition of infinity, but I would guess that the subtraction would be $$\{-\infty, \infty\}$$

We are talking about two distinct sets... one set is a subset of the other set. If you take away all the elements of the subset what are we left with?

In other words...using brackets for your set does not seem to make any sense. At least not up to any of the math classes I have taken.

mattmns
I am no math expert, but this is what I was thinking, I may have misunderstood you.

If we have a set that contains all the elements up to infinity and down to negative infinity, we have $$\{ x | -\infty < x < \infty \}$$ which is denoted by $$( -\infty, \infty )$$

If we then look at the set including infinty and negative infinity we have $$\{ x | -\infty \leq x \leq \infty \}$$ which is denoted by $$[ -\infty, \infty ]$$

If we then subtract the latter set by the former (what I am guessing you meant by the - sign, set difference of the two sets), we will get a set with 2 elements: $$-\infty, \infty$$
Which I wrote as the set: $$\{ -\infty, \infty \}$$

Keep in mind I am no math expert, so I could easily be wrong.

Last edited:
Townsend
mattmns said:
I am no math expert, but this is what I was thinking, I may have misunderstood you.

If we have a set that contains all the elements up to infinity and down to negative infinity, we have $$\{ x | -\infty < x < \infty \}$$ which is denoted by $$( -\infty, \infty )$$

If we then look at the set including infinty and negative infinity we have $$\{ x | -\infty \leq x \leq \infty \}$$ which is denoted by $$[ -\infty, \infty ]$$

If we then subtract the latter set by the former (what I am guessing you meant by the - sign, set difference of the two sets), we will get a set with 2 elements: $$-\infty, \infty$$

Keep in mind I am no math expert, so I could easily be wrong.

Well that's just it...infinity is not an element of the set but a symbol that means it just goes on and on...

For example $$(- \infty,\infty)$$ could be written as the real number line. Where on that number line is infinity? It is nowhere on the line that I can think of...

So how could it be included in the set? Which makes writing infinity with the closed bracket kind of non-sense.

Do you see what I mean?

mattmns
Ohh, you did not like my use of square brackets. Pff, math standards I was using it more of as a joke

Townsend
mattmns said:
Ohh, you did not like my use of square brackets. Pff, math standards I was using it more of as a joke

I don't know if they're standards so much...more like conventions so people understand what is meant by symbols...

Dr.Brain
ok I want more ideas.

Townsend
Dr.Brain said:
ok I want more ideas.

Try concentrating harder then...

Gold Member
how about just plain $$\infty$$?

or $$\overline{\infty}$$


text:
# Homework Help: Entropy For Irrevesible Process

1. May 12, 2013

### morrobay

1. The problem statement, all variables and given/known data
Two 100g Aluminum cubes with T1 = 80° C and T2 = 20°C
Specific heat of Al is .22 cal/g/°C. The cubes are placed in contact and in short period of time
a quantity of heat, dQ , is transferred from T1 cube to T2 cube.
The cubes temperatures now are 75°C and 25°C. After a little math : dQ = 640 Joules
The total entropy of the two cubes before dQ was: 22.3 J/K and after dQ was 27.5 J/K

2. Relevant equations
S2-S1 > ∫12 dQ/T
ΔS = 5.2 J/K > ∫12 dQ/T This should be evaluated :
ln dQ/T - ln dQ/T . The question on this is what are the T values here ?
Is it necessary to do two evaluations, one for hotter object and another for cooler object ?
,

3. The attempt at a solution
S2-S1 = 5.2J/K
For hotter object ln 460 J/348K - ln 460J/353K = .01
For cooler object ln 460J/293K - ln 460J/298K = .02
1. The problem statement, all variables and given/known data

2. Relevant equations

3. The attempt at a solution

2. May 12, 2013

### Staff: Mentor

Throughout the heat interchange, the temperature at the interface between the two cubes was 50C = 323 K. For an irreversible processes, if you are evaluating dQ/T for testing the Clausius inequality, you use the temperature at the boundary (interface). What was the integral of dQ/T for the hotter body? What was the integral of dQ/T for the colder body? What was the sum of these? How does that compare with the actual entropy change?

3. May 12, 2013

### morrobay

In the attempt of solution above is the evaluation of integral for hotter and cooler object correct ?
Total entropy change was + 5.2J/K
dQ/T for 323 K = 640 J/323K = 1.98 J/K

The inequality certainly holds , my question is whether I evaluated the two integrals correctly
with temperatures before and after dQ for both objects.
S2-S1 = 5.2J/K > 1.98 J/K (.03 )

Last edited: May 12, 2013
4. May 12, 2013

### Staff: Mentor

No. For the hotter body, the dQ/T is -640/323 = -1.98. For the colder body dQ/T is +640/323 = +1.98. So, the total dQ/T for both bodies is zero. This is the value that you are supposed to compare with the sum of the actual entropy changes for the two bodies, which is

$$ΔS=mC_v(\ln (348/353)+\ln (298/293))$$

5. May 13, 2013

### morrobay

With m = mass = 200g and Cv= specific heat Al = .22cal/g/C
ΔS = 200g*.92J/g/C * ln 348/353 + ln 298/293 = .48J/K
Good news , with math correction total entropy change for both objects S2 - S1 =
27.54J/K - 27.11J/k = .43J/K This value ( see work below ) is very close to above value
arrived at independently

Example for entropy , Q/T, for 100g object at 80 C , specific heat = .92J/g/C before dQ , S1
100g*80 C * .92J/g/C = 7360 J/353K = 20.84J/K + 6.27J/K for 20c object = 27.11J/K

Last edited: May 13, 2013
6. May 13, 2013

### Staff: Mentor

ΔShot=92ln(348/353)=-1.05 J/K

ΔScold=92ln(298/293)=+1.55 J/K

(dQ/T)hot=-(92)(5)/323=-1.43 J/K

(dQ/T)cold=+(92)(5)/323=+1.43 J/K

The inequality must be satisfied not only for the system of two masses as a whole, but also for each mass individually. For the system as a whole,

ΔShot+ΔScold=-1.05 +1.55=0.50 J/K

(dQ/T)hot+(dQ/T)cold=-1.43+1.43=0 J/K

For the hot mass:
-1.05>-1.43

For the cold mass:
1.55>+1.43

7. May 15, 2013

### DrDu

As I said in the other forum, you are generally right that T may not even be defined during an irreversible process. I think here you are supposed to assume that the thermal bridge between the two cubes has much lower heat conductance than the aluminium blocks. Then the temperature within the blocks is homogeneous and you can relate it to dQ=C_v dT.

8. May 15, 2013

### Staff: Mentor

Not really. If the interface is infinitely conductive, then, by symmetry, the temperature at the interface would have to be 50 C throughout the heat exchange in this problem. If you could not be sure what the temperature at the interface would be in any irreversible process, then the temperature in Clausius' inequality would be meaningless, except for a reversible process, in which case the equality would apply.

Chet

9. May 15, 2013

### Andrew Mason

I have not seen the Clausius inequality used in this way. The Clausius inequality relates to a cyclical process.

Since entropy is a state function, when the system returns to its original state there is no change in entropy: ΔSsys = ∫dQrev/T = 0.

However, if the cycle is not reversible ∫dQ/T ≤ 0 over the entire cycle where dQ is the actual heat flow into/out of the system (ie. this is strictly a path function, not a state function). This is because for a given amount of heat flow into the system, less work is done than in the reversible case so there is more heat flow out of the system to the cold reservoir than in the reversible case. This makes ∫dQ/T < ∫dQrev/T.

AM

Last edited: May 15, 2013
10. May 15, 2013

### Staff: Mentor

The form of the Clausius inequality that I am used to is
$$dS≥dQ/T$$
There have been numerous recent references to this form of the Clausius inequality on PF.

Chet


text:
# Laplace distribution as a mixture of normals

Previously on this blog we showed that the t-distribution can be expressed as a continuous mixture of normal distributions. Today, I learned from this paper that the Laplace distribution can be viewed as a continuous mixture of normal distributions as well.

The Laplace distribution with mean $\mu \in \mathbb{R}$ and scale $b > 0$ has the probability density function

\begin{aligned} f(x) = \frac{1}{2b} \exp \left(-\frac{|x-\mu|}{b} \right). \end{aligned}

(The Laplace distribution is sometimes known as the double exponential distribution, since each tail corresponds to that for an exponential random variable.) Note that if we can show that the Laplace distribution with mean $0$ is a mixture of normals, then by shifting all these normals by $\mu$, it follows that the Laplace distribution with mean $\mu$ is also a mixture of normals.

Fix $b > 0$. Let $W \sim \text{Exp}(\frac{1}{2b^2})$, i.e. $f_W(w) = \dfrac{1}{2b^2} \exp \left(-\dfrac{x}{2b^2} \right)$ for $w \geq 0$, and let $X \mid W = w \sim \mathcal{N}(0, w)$. We claim that $X$ has the Laplace distribution with mean $0$ and scale $b$. This is equivalent to showing that for any $x$,

\begin{aligned} f_X(x) &= \frac{1}{2b} \exp \left(-\frac{|x|}{b} \right), \\ \Leftrightarrow \quad \int_0^\infty f_{X \mid W = w}(x) f_W(w) dw &= \frac{1}{2b} \exp \left(-\frac{|x|}{b} \right). \end{aligned}

The key to showing this identity is noticing that the integrand on the LHS looks very much like the probability density function (PDF) of the inverse Gaussian distribution. Letting $\lambda = |x|^2$, $\mu = |x|b$ and $Z$ be an inverse Gaussian random variable with mean $\mu$ and shape $\lambda$,

\begin{aligned} \int_0^\infty f_{X \mid W = w}(x) f_W(w) dw &= \int_0^\infty \frac{1}{\sqrt{2\pi w}} \exp \left( - \frac{x^2}{2w} \right) \frac{1}{2b^2} \exp \left( - \frac{w}{2b^2} \right) dw \\ &= \frac{1}{2b^2} \int_0^\infty \frac{1}{\sqrt{2\pi w}} \exp \left( - \frac{w^2 + |x|^2b^2}{2b^2 w} \right) dw \\ &= \frac{1}{2b^2} \int_0^\infty \frac{1}{\sqrt{2\pi w}} \exp \left( - \frac{(w - |x|b)^2}{2b^2 w} - \frac{2w|x|b}{2b^2w} \right) dw \\ &= \frac{1}{2b^2} e^{-|x|/b} \int_0^\infty \frac{1}{\sqrt{2\pi w}} \exp \left( - \frac{|x|^2(w - |x|b)^2}{2|x|^2b^2 w} \right) dw \\ &= \frac{1}{2b^2} e^{-|x|/b} \frac{1}{\sqrt{\lambda}} \int_0^\infty w \frac{\sqrt{\lambda}}{\sqrt{2\pi w^3}} \exp \left( - \frac{\lambda(w - \mu)^2}{2\mu^2 w} \right) dw \\ &= \frac{1}{2b^2} e^{-|x|/b} \frac{1}{|x|} \mathbb{E}[Z] \\ &= \frac{1}{2|x|b^2} e^{-|x|/b} \mu \\ &= \frac{1}{2b} e^{-|x|/b}. \end{aligned}

## 3 thoughts on “Laplace distribution as a mixture of normals”

1. Hi, there is a small typo in the formula $W\sim \mathrm{Exp}(\frac{1}{2b^2})$ where you forget the square of b.

Like

• Thanks, I’ve fixed it!

Like


text:
## Differential and Integral Equations

### Asymptotic profiles to the solutions for a nonlinear damped wave equation

#### Abstract

We consider the Cauchy problem for a nonlinear damped wave equation. Under suitable assumptions of the nonlinear term and the initial functions, the Cauchy problem has a global-in-time solution $u$ behaving like the Gauss kernel as time tends to infinity. In this paper we show the asymptotic profiles to the solutions and give precise decay estimates on the difference between the solutions and their asymptotic profiles. Our results are based on the $L^p$--$L^q$-type decomposition of the fundamental solutions of the linearized damped wave equation and asymptotic expansion of the solution of a nonlinear heat equation.

#### Article information

Source
Differential Integral Equations, Volume 26, Number 7/8 (2013), 781-814.

Dates
First available in Project Euclid: 20 May 2013


text:
# How do you convert the following phrases into math expressions, and then evaluate the expressions: 3 increased by 33?

Sep 2, 2017

See a solution process below:

#### Explanation:

The phrase "increased by" means to add something to something else.

In this problem it means to add $33$ to $3$ which we can write as:

$3 + 33$

To evaluate:

$3 + 33 \implies 36$


text:
# Distributed Random Forest (DRF)¶

## Introduction¶

Distributed Random Forest (DRF) is a powerful classification and regression tool. When given a set of data, DRF generates a forest of classification or regression trees, rather than a single classification or regression tree. Each of these trees is a weak learner built on a subset of rows and columns. More trees will reduce the variance. Both classification and regression take the average prediction over all of their trees to make a final prediction, whether predicting for a class or numeric value. (Note: For a categorical response column, DRF maps factors (e.g. ‘dog’, ‘cat’, ‘mouse) in lexicographic order to a name lookup array with integer indices (e.g. ‘cat -> 0, ‘dog’ -> 1, ‘mouse’ -> 2.)

The current version of DRF is fundamentally the same as in previous versions of H2O (same algorithmic steps, same histogramming techniques), with the exception of the following changes:

• Improved ability to train on categorical variables (using the nbins_cats parameter)

• Minor changes in histogramming logic for some corner cases

• By default, DRF builds half as many trees for binomial problems, similar to GBM: it uses a single tree to estimate class 0 (probability “p0”), and then computes the probability of class 0 as $$1.0 - p0$$. For multiclass problems, a tree is used to estimate the probability of each class separately.

There was some code cleanup and refactoring to support the following features:

• Per-row observation weights

• N-fold cross-validation

DRF no longer has a special-cased histogram for classification (class DBinomHistogram has been superseded by DRealHistogram) since it was not applicable to cases with observation weights or for cross-validation.

## Extremely Randomized Trees¶

In random forests, a random subset of candidate features is used to determine the most discriminative thresholds that are picked as the splitting rule. In extremely randomized trees (XRT), randomness goes one step further in the way that splits are computed. As in random forests, a random subset of candidate features is used, but instead of looking for the most discriminative thresholds, thresholds are drawn at random for each candidate feature, and the best of these randomly generated thresholds is picked as the splitting rule. This usually allows to reduce the variance of the model a bit more, at the expense of a slightly greater increase in bias.

H2O supports extremely randomized trees (XRT) via histogram_type="Random". When this is specified, the algorithm will sample N-1 points from min…max and use the sorted list of those to find the best split. The cut points are random rather than uniform. For example, to generate 4 bins for some feature ranging from 0-100, 3 random numbers would be generated in this range (13.2, 89.12, 45.0). The sorted list of these random numbers forms the histogram bin boundaries e.g. (0-13.2, 13.2-45.0, 45.0-89.12, 89.12-100).

## Defining a DRF Model¶

• model_id: (Optional) Specify a custom name for the model to use as a reference. By default, H2O automatically generates a destination key.

• training_frame: (Required) Specify the dataset used to build the model. NOTE: In Flow, if you click the Build a model button from the Parse cell, the training frame is entered automatically.

• validation_frame: (Optional) Specify the dataset used to evaluate the accuracy of the model.

• nfolds: Specify the number of folds for cross-validation.

• y: (Required) Specify the column to use as the dependent variable. The data can be numeric or categorical.

• x: Specify a vector containing the names or indices of the predictor variables to use when building the model. If x is missing, then all columns except y are used.

• keep_cross_validation_models: Specify whether to keep the cross-validated models. Keeping cross-validation models may consume significantly more memory in the H2O cluster. This option defaults to TRUE.

• keep_cross_validation_predictions: Enable this option to keep the cross-validation prediction.

• keep_cross_validation_fold_assignment: Enable this option to preserve the cross-validation fold assignment.

• score_each_iteration: (Optional) Enable this option to score during each iteration of the model training.

• score_tree_interval: Score the model after every so many trees. Disabled if set to 0.

• fold_assignment-: (Applicable only if a value for nfolds is specified and fold_column is not specified) Specify the cross-validation fold assignment scheme. The available options are AUTO (which is Random), Random, Modulo, or Stratified (which will stratify the folds based on the response variable for classification problems).

• fold_column: Specify the column that contains the cross-validation fold index assignment per observation.

• ignored_columns: (Optional, Python and Flow only) Specify the column or columns to be excluded from the model. In Flow, click the checkbox next to a column name to add it to the list of columns excluded from the model. To add all columns, click the All button. To remove a column from the list of ignored columns, click the X next to the column name. To remove all columns from the list of ignored columns, click the None button. To search for a specific column, type the column name in the Search field above the column list. To only show columns with a specific percentage of missing values, specify the percentage in the Only show columns with more than 0% missing values field. To change the selections for the hidden columns, use the Select Visible or Deselect Visible buttons.

• ignore_const_cols: Specify whether to ignore constant training columns, since no information can be gained from them. This option is enabled by default.

• weights_column: Specify a column to use for the observation weights, which are used for bias correction. The specified weights_column must be included in the specified training_frame.

Python only: To use a weights column when passing an H2OFrame to x instead of a list of column names, the specified training_frame must contain the specified weights_column.

Note: Weights are per-row observation weights and do not increase the size of the data frame. This is typically the number of times a row is repeated, but non-integer values are supported as well. During training, rows with higher weights matter more, due to the larger loss function pre-factor.
• balance_classes: Oversample the minority classes to balance the class distribution. This option is not enabled by default and can increase the data frame size. This option is only applicable for classification.

• class_sampling_factors: Specify the per-class (in lexicographical order) over/under-sampling ratios. By default, these ratios are automatically computed during training to obtain the class balance. Note that this requires balance_classes=true.

• max_after_balance_size: Specify the maximum relative size of the training data after balancing class counts (balance_classes must be enabled). The value can be less than 1.0.

• max_hit_ratio_k: Specify the maximum number (top K) of predictions to use for hit ratio computation. Applicable to multi-class only. To disable, enter 0.

• ntrees: Specify the number of trees.

• max_depth: Specify the maximum tree depth. Higher values will make the model more complex and can lead to overfitting. Setting this value to 0 specifies no limit. This value defaults to 20.

• min_rows: Specify the minimum number of observations for a leaf (nodesize in R).

• nbins: (Numerical/real/int only) Specify the number of bins for the histogram to build, then split at the best point.

• nbins_top_level: (For numerical/real/int columns only) Specify the minimum number of bins at the root level to use to build the histogram. This number will then be decreased by a factor of two per level.

• nbins_cats: (Categorical/enums only) Specify the maximum number of bins for the histogram to build, then split at the best point. Higher values can lead to more overfitting. The levels are ordered alphabetically; if there are more levels than bins, adjacent levels share bins. This value has a more significant impact on model fitness than nbins. Larger values may increase runtime, especially for deep trees and large clusters, so tuning may be required to find the optimal value for your configuration.

• r2_stopping: r2_stopping is no longer supported and will be ignored if set - please use stopping_rounds, stopping_metric, and stopping_tolerance instead.

• stopping_rounds-: Stops training when the option selected for stopping_metric doesn’t improve for the specified number of training rounds, based on a simple moving average. To disable this feature, specify 0. The metric is computed on the validation data (if provided); otherwise, training data is used.

Note: If cross-validation is enabled:

• All cross-validation models stop training when the validation metric doesn’t improve.

• The main model runs for the mean number of epochs.

• N+1 models may be off by the number specified for stopping_rounds from the best model, but the cross-validation metric estimates the performance of the main model for the resulting number of epochs (which may be fewer than the specified number of epochs).

• stopping_metric: Specify the metric to use for early stopping. The available options are:

• AUTO: This defaults to logloss for classification, deviance for regression, and anomaly_score for Isolation Forest. Note that custom and custom_increasing can only be used in GBM and DRF with the Python client. Must be one of: AUTO, anomaly_score. Defaults to AUTO.

• anomaly_score (Isolation Forest only)

• deviance

• logloss

• MSE

• RMSE

• MAE

• RMSLE

• AUC (area under the ROC curve)

• AUCPR (area under the Precision-Recall curve)

• lift_top_group

• misclassification

• mean_per_class_error

• custom (Python client only)

• custom_increasing (Python client only)

• stopping_tolerance: Specify the relative tolerance for the metric-based stopping to stop training if the improvement is less than this value.

• max_runtime_secs: Maximum allowed runtime in seconds for model training. Use 0 to disable.

• seed: Specify the random number generator (RNG) seed for algorithm components dependent on randomization. The seed is consistent for each H2O instance so that you can create models with the same starting conditions in alternative configurations.

• build_tree_one_node: Specify whether to run on a single node. This is suitable for small datasets as there is no network overhead but fewer CPUs are used

• mtries: Specify the columns to randomly select at each level. If the default value of -1 is used, the number of variables is the square root of the number of columns for classification and p/3 for regression (where p is the number of predictors). If -2 is specified, all features of DRF are used. Valid values for this option are -2, -1, and any value >= 1.

• sample_rate: Specify the row sampling rate (x-axis). (Note that this method is sample without replacement.) The range is 0.0 to 1.0, and this value defaults to 0.6320000291. Higher values may improve training accuracy. Test accuracy improves when either columns or rows are sampled. For details, refer to “Stochastic Gradient Boosting” (Friedman, 1999).

• sample_rate_per_class: When building models from imbalanced datasets, this option specifies that each tree in the ensemble should sample from the full training dataset using a per-class-specific sampling rate rather than a global sample factor (as with sample_rate). The range for this option is 0.0 to 1.0. Note that this method is sample without replacement.

• binomial_double_trees: (Binary classification only) Build twice as many trees (one per class). Enabling this option can lead to higher accuracy, while disabling can result in faster model building. This option is disabled by default.

• checkpoint: Enter a model key associated with a previously trained model. Use this option to build a new model as a continuation of a previously generated model.

• col_sample_rate_change_per_level: This option specifies to change the column sampling rate as a function of the depth in the tree. This can be a value > 0.0 and <= 2.0 and defaults to 1. (Note that this method is sample without replacement.) For example:

level 1: col_sample_rate

level 2: col_sample_rate * factor

level 3: col_sample_rate * factor^2

level 4: col_sample_rate * factor^3

etc.

• col_sample_rate_per_tree: Specify the column sample rate per tree. This can be a value from 0.0 to 1.0 and defaults to 1. Note that this method is sample without replacement.

• min_split_improvement: The value of this option specifies the minimum relative improvement in squared error reduction in order for a split to happen. When properly tuned, this option can help reduce overfitting. Optimal values would be in the 1e-10…1e-3 range.

• histogram_type: By default (AUTO) DRF bins from min…max in steps of (max-min)/N. Random split points or quantile-based split points can be selected as well. RoundRobin can be specified to cycle through all histogram types (one per tree). Use this option to specify the type of histogram to use for finding optimal split points:

• AUTO

• Random

• QuantilesGlobal

• RoundRobin

• categorical_encoding: Specify one of the following encoding schemes for handling categorical features:

• auto or AUTO: Allow the algorithm to decide (default). In DRF, the algorithm will automatically perform enum encoding.

• enum or Enum: 1 column per categorical feature

• enum_limited or EnumLimited: Automatically reduce categorical levels to the most prevalent ones during training and only keep the T (10) most frequent levels.

• one_hot_explicit or OneHotExplicit: N+1 new columns for categorical features with N levels

• binary or Binary: No more than 32 columns per categorical feature

• eigen or Eigen: k columns per categorical feature, keeping projections of one-hot-encoded matrix onto k-dim eigen space only

• label_encoder or LabelEncoder: Convert every enum into the integer of its index (for example, level 0 -> 0, level 1 -> 1, etc.)

• sort_by_response or SortByResponse: Reorders the levels by the mean response (for example, the level with lowest response -> 0, the level with second-lowest response -> 1, etc.). This is useful in GBM/DRF, for example, when you have more levels than nbins_cats, and where the top level splits now have a chance at separating the data with a split. Note that this requires a specified response column.

• calibrate_model: Use Platt scaling to calculate calibrated class probabilities. Defaults to False.

• calibration_frame: Specifies the frame to be used for Platt scaling.

• verbose: Print scoring history to the console. For DRF, metrics are per tree. This value defaults to FALSE.

• custom_metric_func: Optionally specify a custom evaluation function.

• export_checkpoints_dir: Specify a directory to which generated models will automatically be exported.

• check_constant_response: Check if the response column is a constant value. If enabled (default), then an exception is thrown if the response column is a constant value. If disabled, then the model will train regardless of the response column being a constant value or not.

• gainslift_bins: The number of bins for a Gains/Lift table. The default value is -1 and makes the binning automatic. To disable this feature, set to 0.

## Interpreting a DRF Model¶

By default, the following output displays:

• Model parameters (hidden)

• A graph of the scoring history (number of trees vs. training MSE)

• A graph of the ROC curve (TPR vs. FPR)

• A graph of the variable importances

• Output (model category, validation metrics, initf)

• Model summary (number of trees, min. depth, max. depth, mean depth, min. leaves, max. leaves, mean leaves)

• Scoring history in tabular format

• Training metrics (model name, checksum name, frame name, frame checksum name, description, model category, duration in ms, scoring time, predictions, MSE, R2, logloss, AUC, GINI)

• Training metrics for thresholds (thresholds, F1, F2, F0Points, Accuracy, Precision, Recall, Specificity, Absolute MCC, min. per-class accuracy, TNS, FNS, FPS, TPS, IDX)

• Maximum metrics (metric, threshold, value, IDX)

• Variable importances in tabular format

## Leaf Node Assignment¶

Trees cluster observations into leaf nodes, and this information can be useful for feature engineering or model interpretability. Use h2o.predict_leaf_node_assignment( model, frame ) to get an H2OFrame with the leaf node assignments, or click the Compute Leafe Node Assignment checkbox when making predictions from Flow. Those leaf nodes represent decision rules that can be fed to other models (i.e., GLM with lambda search and strong rules) to obtain a limited set of the most important rules.

## Examples¶

Below is a simple example showing how to build a Random Forest model.

library(h2o)
h2o.init()

# Import the cars dataset into H2O:
cars <- h2o.importFile("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv")

# Set the predictors and response;
# set the response as a factor:
cars["economy_20mpg"] <- as.factor(cars["economy_20mpg"])
predictors <- c("displacement", "power", "weight", "acceleration", "year")
response <- "economy_20mpg"

# Split the dataset into a train and valid set:
cars_split <- h2o.splitFrame(data = cars, ratios = 0.8, seed = 1234)
train <- cars_split[[1]]
valid <- cars_split[[2]]

# Build and train the model:
cars_drf <- h2o.randomForest(x = predictors,
y = response,
ntrees = 10,
max_depth = 5,
min_rows = 10,
calibrate_model = TRUE,
calibration_frame = valid,
binomial_double_trees = TRUE,
training_frame = train,
validation_frame = valid)

# Eval performance:
perf <- h2o.performance(cars_drf)

# Generate predictions on a validation set (if necessary):
predict <- h2o.predict(cars_drf, newdata = valid)

import h2o
from h2o.estimators import H2ORandomForestEstimator
h2o.init()

# Import the cars dataset into H2O:
cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv")

# Set the predictors and response;
# set the response as a factor:
cars["economy_20mpg"] = cars["economy_20mpg"].asfactor()
predictors = ["displacement","power","weight","acceleration","year"]
response = "economy_20mpg"

# Split the dataset into a train and valid set:
train, valid = cars.split_frame(ratios=[.8], seed=1234)

# Build and train the model:
cars_drf = H2ORandomForestEstimator(ntrees=10,
max_depth=5,
min_rows=10,
calibrate_model=True,
calibration_frame=valid,
binomial_double_trees=True)
cars_drf.train(x=predictors,
y=response,
training_frame=train,
validation_frame=valid

# Eval performance:
perf = cars_drf.model_performance()

# Generate predictions on a validation set (if necessary):
pred = cars_drf.predict(valid)

## FAQ¶

• How does the algorithm handle missing values during training?

Missing values are interpreted as containing information (i.e., missing for a reason), rather than missing at random. During tree building, split decisions for every node are found by minimizing the loss function and treating missing values as a separate category that can go either left or right.

Note: Unlike in GLM, in DRF numerical values are handled the same way as categorical values. Missing values are not imputed with the mean, as is done by default in GLM.

• How does the algorithm handle missing values during testing?

During scoring, missing values follow the optimal path that was determined for them during training (minimized loss function).

• What happens if the response has missing values?

No errors will occur, but nothing will be learned from rows containing missing values in the response column.

• What happens when you try to predict on a categorical level not seen during training?

DRF converts a new categorical level to a NA value in the test set, and then splits left on the NA value during scoring. The algorithm splits left on NA values because, during training, NA values are grouped with the outliers in the left-most bin.

• Does it matter if the data is sorted?

No.

• Should data be shuffled before training?

No.

• How does the algorithm handle highly imbalanced data in a response column?

Specify balance_classes, class_sampling_factors and max_after_balance_size to control over/under-sampling.

• What if there are a large number of columns?

DRFs are best for datasets with fewer than a few thousand columns.

• What if there are a large number of categorical factor levels?

Large numbers of categoricals are handled very efficiently - there is never any one-hot encoding.

• Does the algo stop splitting when all the possible splits lead to worse error measures?

It does if you use min_split_improvement (min_split_improvement turned ON by default (0.00001).) When properly tuned, this option can help reduce overfitting.

• When does the algo stop splitting on an internal node?

A single tree will stop splitting when there are no more splits that satisfy the minimum rows parameter, if it reaches max_depth, or if there are no splits that satisfy the min_split_improvement parameter.

• How does DRF decide which feature to split on?

It splits on the column and level that results in the greatest reduction in residual sum of the squares (RSS) in the subtree at that point. It considers all fields available from the algorithm. Note that any use of column sampling and row sampling will cause each decision to not consider all data points, and that this is on purpose to generate more robust trees. To find the best level, the histogram binning process is used to quickly compute the potential MSE of each possible split. The number of bins is controlled via nbins_cats for categoricals, the pair of nbins (the number of bins for the histogram to build, then split at the best point), and nbins_top_level (the minimum number of bins at the root level to use to build the histogram). This number will then be decreased by a factor of two per level.

For nbins_top_level, higher = more precise, but potentially more prone to overfitting. Higher also takes more memory and possibly longer to run.

• What is the difference between nbins and nbins_top_level?

nbins and nbins_top_level are both for numerics (real and integer). nbins_top_level is the number of bins DRF uses at the top of each tree. It then divides by 2 at each ensuing level to find a new number. nbins controls when DRF stops dividing by 2.

• How is variable importance calculated for DRF?

When calculating variable importances, H2O-3 looks at the squared error before and after the split using a particular variable. The difference is the improvement. H2O uses the improvement in squared error for each feature that was split on (rather than the accuracy). Each features improvement is then summed up at the end to get its total feature importance (and then scaled between 0-1).

• How is column sampling implemented for DRF?

For an example model using:

• 100 columns

• col_sample_rate_per_tree is 0.602

• mtries is -1 or 7 (refers to the number of active predictor columns for the dataset)

For each tree, the floor is used to determine the number of columns that are randomly picked (for this example, (0.602*100)=60 out of the 100 columns).

For classification cases where mtries=-1, the square root is randomly chosen for each split decision (out of the total 60 - for this example, ($$\sqrt{100}$$ = 10 columns).

For regression, the floor is used for each split by default (in this example, (100/3)=33 columns). If mtries=7, then 7 columns are picked for each split decision (out of the 60).

mtries is configured independently of col_sample_rate_per_tree, but it can be limited by it. For example, if col_sample_rate_per_tree=0.01, then there’s only one column left for each split, regardless of how large the value for mtries is.

• Why does performance appear slower in DRF than in GBM?

With DRF, depth and size of trees can result in speed tradeoffs.

By default, DRF will go to depth 20, which can lead to up to 1+2+4+8+…+2^19 ~ 1M nodes to be split, and for every one of them, mtries=sqrt(4600)=67 columns need to be considered for splitting. This results in a total work of finding up to 1M*67 ~ 67M split points per tree. Usually, many of the leaves don’t go to depth 20, so the actual number is less. (You can inspect the model to see that value.)

By default, GBM will go to depth 5, so only 1+2+4+8+16 = 31 nodes to be split, and for every one of them, all 4600 columns need to be considered. This results in a total work of finding up to 31*4600 ~ 143k split points (often all are needed) per tree.

This is why the shallow depth of GBM is one of the reasons it’s great for wide (for tree purposes) datasets. To make DRF faster, consider decreasing max_depth and/or mtries and/or ntrees.

For both algorithms, finding one split requires a pass over one column and all rows. Assume a dataset with 250k rows and 500 columns. GBM can take minutes minutes, while DRF may take hours. This is because:

• Assuming the above, GBM needs to pass over up to 31*500*250k = 4 billion numbers per tree, and assuming 50 trees, that’s up to (typically equal to) 200 billion numbers in 11 minutes, or 300M per second, which is pretty fast.

• DRF needs to pass over up to 1M*22*250k = 5500 billion numbers per tree, and assuming 50 trees, that’s up to 275 trillion numbers, which can take a few hours

## DRF Algorithm¶

Building Random Forest at Scale from Sri Ambati


text:
K-theory of group $C^*$-algebras and applications
A rapid development of K-theory of group $C^*$-algebras started about 40 years ago. To a large extent this was related with applications to topology of smooth manifolds (the Novikov conjecture on higher signatures) and to representation theory of semisimple Lie groups (and discrete discrete series in particular). But the topic of K-theory for group $C^*$-algebras is very attractive also by its deep relations with index theory of elliptic operators. There are several unsolved, very challenging conjectures in this theory, such as the Baum-Connes conjecture and the Kadison-Kaplansky conjecture. I will try to give a survey of the current status of this theory, without going into deep technical details. This talk will be accessible to graduate students. (Some knowledge of Hilbert space theory will be required).


text:
Critical Angle Of Glass Water Interface » kevinhanes.net

May 14, 2017 · What is the critical angle for the interface between water and crown glass?To be internally reflected,the light must start in which material? The Critical Angle of Reflection.At the interface, the light wave is refracted by the angle q r and passes through the air in a straight trajectory after being deviated. In order to operate the tutorial, use the Incident Angle slider to adjust the value of the incident light wave impacting the interface between a. Critical angle-The angle at which the incident ray after refraction grazes is called the critical angle. Answer-Critical angle = 54.57° Explaination- Given-μi = 1.62 μr = 1.32Solution-According to Snell's law for refraction, μi.sini = μr.sinr At critical angle of incidence, i = c,.

A glass block with index of refraction 1.50 is immersed in water whose index of refraction is 1.33. The critical angle at the glass-water interface is 56.3º 62.5º 41.9º 48.8º 6.5º. For glass-air interface,the formula for critical angle is given by sin i c = 1/ a μ g The critical angle i’c for glass water interface is given by Sin ic' = 1/ w μ g. Light is incident at an angle of 60o at an air to glass interface. If the angle of refraction inside the glass is 32o, then calculate the speed of light within the glass. 1.84x108 m/s. refraction is 1.33. The critical angle at the glass–water interface is A 6.5º B 41.9º C 48.8º D 56.3º E 62.5º Ans: E 14. Light is incident on a piece of glass in air at an angle of 37.0º from the normal. If the index of refraction of the glass is 1.50, the angle that the refracted ray makes with the.

Nov 14, 2017 · It is given that the critical angle of glass in air is $41.8^o$ and that the refractive index of water is $1.33.$ $\frac1\mu = \frac\sin i\sin r, \qquad$ where, $\mu$ is the refractive index of g. Sep 30, 2013 · Total internal reflection is the complete reflection of a ray of light that is traveling within one medium, such as water or glass, from the boundary with a second medium back into the first. Aug 07, 2010 · A glass is half-full of water, with a layer of vegetable oil n = 1.47 floating on top. A ray of light traveling downward through the oil is incident on the water at an angle of 62.4°. Determine the critical angle for the oil-water interface θc = ° Decide whether the ray will penetrate into the water. The ray of light will enter the water. The critical angle at this interface is: Because the angle of incidence is less than the critical angle, the beam will escape from the piece of diamond here. The angle of refraction can be found from Snell's law: Back to the lecture note home page.


text:
# I don't think I can do it

Calculus Level 5

Find the area of the figure bounded by the curve $$x^3+y^3=1729xy$$.

If the answer comes as $$\frac{A^2}{B}$$ where $$A$$ and $$B$$ are co-prime positive integers. Find $$A+B$$.

×


text:
# Index \see command not italicized in french document

I'm using imakeidx and polyglossia packages, main language: french.

I have a nice small index with some \see commands. But the word “voir“ (“see“ in french) printed in the document is not in italics.

I tried out the commands below in the preamble:

\newcommand*\see[2]{\emph{\seename} #1}

or

\renewcommand*{\seename}{\emph{voir}}

but nothing changes.

I made a test by changing the main language to english, and it works well with “see” in italics.

Could someone kindly help me ? Thanks

PS : here is a minimal example…

\documentclass[12pt]{scrreprt}
\usepackage{fontspec}
\setmainfont{Linux Libertine O}
\setsansfont{Linux Biolinum O}
\setmonofont{DejaVu Sans Mono}[Scale=MatchLowercase]
\usepackage{xunicode}
\usepackage{polyglossia}
\setmainlanguage{french}

\usepackage{imakeidx} \makeindex

\begin{document}

Bla bla bla\index{word-A}.

\index{word-AA|see{word-A}}
\printindex

\end{document}

• Use this in your preamble: \def\see{\emph{voir}~}. Jan 10 '21 at 20:47
• @Bernard Thanks for your suggestion, but the inconvenient about this solution is that it adds a page number to the "see" index entry, which is not the desired behavior. But I realized that maybe I didn't expressed myself correctly, because the problem here is not about the \see command, as I said, but the \index command with the following syntax:\index{a|see{b}}. Sorry about it. Jan 11 '21 at 8:48

It is a bug in gloss-french.ldf, which has

\def\seename{\emph{voir}}%
\def\alsoname{\emph{voir aussi}}%

in the code for \captionsfrench. The \emph should be removed, because it is already in the standard definition of \see.

What happens is that \see{word-A}{1} in the .ind file becomes, according to the standard definition of \see,

\emph{\seename} word-A

which in turn becomes

\emph{\emph{voir}} word-A

and double emphasis chooses upright type. You can choose one of the following fixes:

1. \appto\captionsfrench{\def\seename{voir}\def\alsoname{voir aussi}}
2. \renewcommand{\see}[2]{\seename\ #1}

The former method fixes the wrong setting made by polyglossia; the latter just avoids double emphasis.

• Thanks for your explanations and the proposed solutions. The fix number 1 works perfectly ! However the fix number 2 deletes the space after "voir". Maybe the reason is that the problem here is not exactly about the \see command (see above my reply to Bernard)... Jan 11 '21 at 8:55
• @gabrielpdp1979 Yes, you're right! A backslash was missing. Jan 11 '21 at 9:02


text:
Article

# Cobordism

In mathematics, the notion of cobordism (also: bordism) is most important in topology and its applications, as well as in topological quantum field theory. It is considered to be the most “computable” relation among manifolds, which is geometrically interesting.[1]

${displaystyle W}$

W

{displaystyle W}

is a cobordism between

${displaystyle M}$

M

{displaystyle M}

and

${displaystyle N}$

N

{displaystyle N}

.

The creator of the cobordism theory is considered to be René Thom (1954)[2]although some crucial ideas were already anticipated by Lev Pontryagin (1950 and before).

## Definition

A cobordism between two manifolds

${displaystyle M}$

M

{displaystyle M}

and

${displaystyle N}$

N

{displaystyle N}

is a manifold

${displaystyle W}$

W

{displaystyle W}

for their edge

${displaystyle partial W}$

W

{displaystyle partial W}

valid

The circle is oriented cobordant to the union of two circles.

${displaystyle M}$

M

{displaystyle M}

and

${displaystyle N}$

N

{displaystyle N}

are then called unoriented cobordant.

More commonly, however, oriented cobordism is used. Two oriented manifolds

${displaystyle M}$

M

{displaystyle M}

and

${displaystyle N}$

N

{displaystyle N}

are called oriented cobordant if there is an oriented manifold

${displaystyle W}$

W

{displaystyle W}

with

orientation, whereby the orientation towards

${displaystyle partial W}$

W

{displaystyle partial W}

the orientation of

${displaystyle W}$

W

{displaystyle W}

induced orientation on the edge and

${displaystyle {overline {N}}}$

N
¯

{displaystyle {overline {N}}

the variety

${displaystyle N}$

N

{displaystyle N}

with the opposite orientation.

## Predictability

According to a theorem of Thom, two manifolds are oriented cobordant if and only if all their Pontrjagin numbers and Stiefel-Whitney numbers agree.

## Applications

Cobordism (oriented or unoriented) defines an equivalence relation, the equivalence classes can be conceived as a group with the disjoint union.

René Thom’s calculation (of the torsion-free part) of the (oriented) cobordism group has numerous applications in algebraic topology and beyond. From it followed directly Hirzebruch’s signature theorem, and the original proof of the Atiyah-Singer index theorem was also built on it

Within topology, the notion was fundamental to the development of surgery theory. Furthermore, the oriented cobordism groups are an example of a generalized cohomology theory.

Topological quantum field theory also builds on the notion of cobordism, see cobordism conjecture.

## Variations of terms

Different variants of the notion of cobordism are of importance, in particular framed cobordism (Pontryagin-Thom construction) and h-cobordism.

## Literature

• John Milnor: A survey of cobordism theory. Enseignement Math. (2) 8 1962 16-23. online (pdf)


text:
• REL
• REL CONCEPTS
• Updating Data: Working with Base Relations

# Updating Data: Working With Base Relations

This concept guide discusses storing, updating, and deleting data in a RAI database using the Rel language. It explains how to interact with and change base relations, specifically through the use of the reserved relations insert and delete. This guide also covers how transactions update the database and then goes into the more advanced topic of reactive updates.

## Introduction

Most databases are not just static collections of data; they evolve over time.

Generally speaking, a database can change in two ways:

1. The data themselves are updated — changed, added, or deleted.
2. The rules that define derived relations are updated — changed, added, or deleted.

It is important to distinguish relations stored on disk, which are often raw data imported from other sources, from relations that are derived from these data via rules. RelationalAI uses the technical terms from the Datalog literature:

• Base relations are stored on disk or other nonvolatile media.
• Derived relations are defined by rules, computed on-demand, and are not persisted — though their definitions can be persisted, as installed code. These are analogous to views in other database systems.

Normally, base relations contain data from external sources that cannot otherwise be captured; they are the “raw data” as far as the database is concerned. By contrast, derived relations are defined and modified by applying rules to the base relations.

Base relations often contain data loaded from CSV files or other external sources.

## Simple Example:

You can directly create a small base relation using insert, described in more detail below:

// update

def insert[:parent] = {("James", "Harry"); ("Harry", "Lily")}
def output = parent

While parent(x, y) is a base and binary relation, the tuples of which are explicitly stored in the database, grandparent(x, y) might be a derived relation, derived from parent and defined by the rule:

// query

def grandparent(x, z) = parent(x, y) and parent(y, z) from y
def output = grandparent

Derived relations can change if the rules or the underlying base relations change.

Base relations only change when the underlying data change.

## Adding Base Relation Data: insert

To add data to a new or existing base relation, you can use the reserved insert relation. The first argument for insert should be a RelName, i.e., a specialized relation starting with : . Data are added to the right-hand side of the definition to create a relation. Other than the important side effect of updating base relations, these definitions are just like any other in Rel, and all the usual Rel constructs can be used.

For example, consider a balance base relation, where balance(x, y) says that account x has balance y. To add data to balance, you can execute this update query:

// update

def insert[:balance] = {("john", 20); ("jack", 30); ("jill", 60)}
def output = balance

This will add three pairs to the balance relation, creating the relation if it does not already exist.

🔎

This code block has issued a RAI SDK execute call using the readonly=false option. This corresponds to an update cell in the RAI notebooks. Execute calls that are not read-only are update transactions, which can change the state of the database, and you can mark them with the “update” label as shown in the code block above.

The insert relation is computed from the current state of the database, determining what gets added to the base relation.

It is even possible to query insert, as in the example below, but it is not itself persisted. The same is true for the delete relation discussed below.

When requested as a query output, these relations are computed from the new state of the database. See the Transactions section below. After the above, insert will have the tuples {(:balance, "john", 20) ; (:balance, "jack", 30) ; (:balance, "jill", 60)}.

In general, insert is defined as any other relation, so the right-hand side of the definition can be a relational expression, defined from other base and derived relations in the database. For example:

// update

def insert[:pairs](x, y) = range(1, 6, 1, x) and x % 2 = 0 and y = x * 2
def output:insert = insert
def output:pairs = pairs

The discussions above hold even if the transaction is read-only — the only difference is that the new database state will not be saved at the end. See the diagram in the Transactions section below.

Note that the readonly option in the query API call has no effect on derived relation definitions. To persist those, use the install_model API call. See the Installing Models concept guide or install cells in the RAI notebooks.

## Removing Base Relation Data: delete

Removing data from the database is analogous to adding them, except here you use the reserved delete relation instead of insert. For example, you can remove all balances lower than 50 with:

// update

def delete[:balance](x, y) = balance(x,y) and y < 50
def output = balance

This has removed the tuples ("jack", 30) and ("john", 20) from the balance relation. You can clear the entire balance relation with:

// update

def delete[:balance] = balance
def output = balance

In general, you can include def delete[:r] = r in a transaction to make sure that r is empty before any new inserts happen. This can produce a warning the first time, if r is not previously defined, but the warning can be ignored.

## Inserts and Deletes in the Same Transaction

Regardless of the order of the definitions, within a single transaction, described in more detail below, deletions are always executed before insertions.

When inserts and deletes are issued together in the same transaction, the deletes are executed first, irrespective of whether the inserts take precedence in the code.

The example below first initializes a unary base relation t:

// update

def insert[:t] = {1; 2}
def output:t = t

You will now add and remove data through an insert and a delete. Note: In the RelationalAI guides, blocks of Rel code are executed as a single transaction. Since they are in the same transaction, the order of these lines does not matter:

// update

def delete[:t] = {1; 2; 10; 20}
def insert[:t] = {1; 2; 3}
def output:t = t
def output:insert = insert
def output:delete = delete

As you can see, 1 and 2 are still in t.

Deleting elements that don’t exist is not an error. This is why you can include extra elements in delete, such as 10 and 20 in this example, that are not in the t relation in the first place.

### Updating Existing Values

In general, to update an existing value, the old value must be deleted — otherwise, the new value will simply be added, and the old and new values will coexist.

For example, suppose you give "jack" a balance of 60:

// update

def delete[:balance] = balance
def insert[:balance]["jack"] = 60
def output = balance

You can update the balance for "jack" with the following transaction, which also removes the old balance:

// update

def delete[:balance]("jack", x) = balance("jack", x)
def insert[:balance]("jack", new) = balance("jack", old) and new = old + 40 from old
def output = balance

If balance is meant to be a function, you can add an integrity constraint for it. A functional dependency on a relation, indicating that the last argument is uniquely determined by the values of the previous ones, can be specified with the built-in relation function:

// install

ic balance_is_a_function { function(balance) }

This IC will make sure that no customer ever has two different account balances — any transaction that violates it will fail. See the Integrity Constraints section for other examples of ICs relevant to data updates.

## Transactions

A database transaction is a unit of work that takes the database from one state S to a new state S_new. Transactions happen atomically, meaning that either the entire transaction succeeds, with no externally visible intermediate states and no interference from other transactions, or the database remains at S. In the case of a read-only transaction, the two states are the same.

Internally, a transaction can be divided into the following steps:

1. Installed sources are updated, if applicable, and are reverted if the transaction fails.
2. Deletes are applied, evaluating delete in state S.
3. Inserts are applied, evaluating insert in state S.
4. Integrity constraints are checked in the state S_new, as a result of steps 2 and 3.
5. If the integrity constraints fail, the entire transaction fails, and the database remains at state S.
6. Outputs, if any, are evaluated at state S_new.
7. Commit, if the transaction is not read-only. The database state is now S_new.

### Current and Updated States

Note that the body of an update refers to the “current” state of the database, before any of the updates are carried out. For example, consider a database where you initialize r to {1; 2} as follows:

// update

def delete[:r] = r // clear r
def delete[:t] = t // clear t
def insert[:r] = {1; 2}
def output:t = t
def output:r = r

Suppose you add some elements to r, but also set the new relation t to be equal to r:

// update

def insert[:r] = {3; 4; 5}
def insert[:t] = r
def output:insert = insert
def output:t = t
def output:r = r

As you can see, the updated r will contain {1; 2; 3; 4; 5}, but t will contain the previous value of r, that is, {1; 2}. This is because when evaluating def insert[:t] = r, the relation r still had the initial values. The current transaction has not been committed, and r has not been changed yet.

The situation is different when you evaluate the output relation. As you can see, insert[:t] in the output will contain the new value of r ({1; 2; 3; 4; 5}), rather than the old one. This means you cannot rely on the output value of insert and delete alone to see deltas. See the Change Tracking section for alternatives.

If you want t to get the latest values of r, you should execute def insert[:t] = r in a separate transaction, after r has been updated:

// update

def insert[:t] = r
def output:t = t
def output:r = r
🔎

In a non-read-only update transaction, insert and delete definitions are evaluated at the start of the transaction. Output relations are evaluated at the end of the transaction and reflect the updates — even if you ask for insert and delete.

### Concurrent Writing Transactions

A common situation that you may experience is trying to write transactions simultaneously to a certain database, such as when you are constantly updating a base relation by inserting new data.

In these cases where there may exist concurrent writes, one — or more — writing transactions will “lose” their current writing slot, i.e., a failed compare-and-swap (CAS) operation. These transactions will be aborted and rerun the writing operation, up to eight retries.

Note that the scope of conflict is the entire database you are working with.

You can verify that a certain transaction has been successful by querying the updated relation. You can also check it by inspecting the transaction log in the RAI Console.

CSV files are also loaded using insert. See the CSV Import how-to guide for details. Here’s a quick recap:

def insert[:my_csv_relation] = load_csv["/my/filename.csv"]
def insert[:my_json_relation] = load_json["/my/filename.json"]

Note that the above will add new data to any previously existing relation. You can fully replace previously loaded data like this:

def delete[:my_csv_relation] = my_csv_relation
def insert[:my_csv_relation] = load_csv["/my/updated_filename.csv"]

The loaded relation can be transformed before being persisted — for example, if only a subset of the external data is persisted. Here, only columns A and B are kept:

@inline
def schema_map[CSV](k, v) = CSV(:A, pos, k) and CSV(:B, pos, v) from pos
def insert[:my_csv_relation] = schema_map[load_csv["/my/filename.csv"]]

### Updating a Single Field in JSON Data

// update

def config[:data] = """{ "a": {"b": {"c": 1, "d": 2}} }"""
def output = myjson

You can update one of its fields as follows:

// update

def delete[:myjson][:a, :b, :c] = myjson[:a, :b, :c]
def insert[:myjson][:a, :b, :c] = 1234
def output = myjson

See the JSON Import and Export how-to guide for more on JSON data.

Installed update rules can be used to implement reactive database logic, where the values in the database are updated according to external events.

As an example, consider the balance base relation again. You can clear it and give "jack" and "jill" a balance of 100:

// update

def delete[:balance] = balance
def insert[:balance] = {("jack", 100); ("jill", 100)}
def output = balance

To transfer money from one account to another, on the condition that the balances do not become negative, you can install the following update logic:

// install

def transfer = {}
def insert[:balance] = {(p1, b1_new) ; (p2, b2_new) }
from
p1, p2, val,
b1_new, b2_new, b1_old, b2_old
where
transfer(p1, p2, val)
and val != 0
and balance(p1, b1_old)
and balance(p2, b2_old)
and b1_new = b1_old - val
and b2_new = b2_old + val
and b1_new >= 0
and b2_new >= 0

def delete[:balance](x, y) = balance(x, y) and insert(:balance, x, new) from new
🔎

The code block above triggered a RelationalAI.install API call, indicated by the install label above it. For more on installing sources, see the Installing Models concept guide.

If the derived relation transfer(p1, p2, val) holds a nonzero value val, the logic above “triggers”, transferring an amount val from account p1 to account p2, provided neither account falls below 0.

Note that even though you have not populated transfer, you are able to install logic in the database that will update the base relation balance if transfer is present.

You can do this even if transfer is not defined. The system will report that transfer is undefined, but the code will still be installed. To avoid this warning, you can add def transfer = {} to the code above. Note that the RAI query engine combines all defs when installing the logic above, so this has no effect when other values are present in the relation. Also, the order in which the definitions are written down is not relevant. See Rel Primer: Basic Syntax for more details.

If the relation transfer has values, the balance transfer happens. The transfer relation is known as the trigger in some formulations, since the update does not happen without it.

Try triggering a balance transfer of 40 from "jack" to "jill" by running:

// update

def transfer = ("jack", "jill", 40)
def output = balance

Since the installed code runs with every query, this tuple in the transfer relation caused the updates to balance to happen.

You can verify the balance updates by installing these integrity constraints:

// install

ic balance_check {
balance["jack"] + balance["jill"] = 200
}

ic nonnegative_balances(x, y) {
balance(x, y) implies y >= 0
}

Executing the same query again triggers another update to balance:

// update

def transfer=("jack", "jill", 40)
def output = balance

If you execute it one more time, balance will be unchanged, since there are not enough funds in the "jack" account:

// update

def transfer=("jack", "jill", 40)
def output = balance

The condition b1_new >= 0 prevented the insert from being triggered. Note that no error happened: The transaction succeeded, but no updates were made.

It is important to remember that installed insert or delete definitions are always executed with each transaction. This might lead to some confusing behavior, if you forget that the code is installed.

If you install an unconditional insert, as in insert[:p] = 1, that value will always be present in the relation and cannot be removed, unless you uninstall the insert. Note that an installed delete can possibly be overridden by an insert, since inserts are executed after deletes. An unconditional insert can only be undone by uninstalling or modifying the corresponding source code.

This behavior might be useful to ensure that certain elements of a relation can never be deleted.

The Console notebook lets you browse and edit installed sources.

If you’re using the API, you can run RelationalAI.list_source(<connection>) to see what’s installed in the database, and RelationalAI.delete_source(<connection>, <source_name>) to remove a particular source.

## Change Tracking

You can debug updates by using auxiliary base relations to see what was inserted and deleted. For example, you can install these rules for inserted and deleted:

// install

def delete[:inserted] = inserted
def delete[:deleted] = deleted
def insert[:inserted](p, x) = insert[p](x) and p != :inserted
def insert[:deleted](p, x) = delete[p](x) and p != :deleted

You can update t and check for inserted and deleted afterwards:

// update

def delete[:t] = t
def insert[:t] = {10; 11; 12}
def output:inserted = inserted
def output:deleted = deleted

Note that inserted and deleted are really supersets of what was changed in the relation. For more accuracy, you can use a snapshot, as described below.

### Snapshotting Relations

You can always snapshot a derived relation or base relation, saving it to disk. Currently, the relation t is {10; 11; 12} (see above). You can now snapshot and update it:

// update

def delete[:t_snapshot] = t_snapshot
def insert[:t_snapshot] = t
def insert[:t] = {100; 101}
def delete[:t] = t
def output = t_snapshot

Note that the relation is captured before the updates are applied. Later, you can compare the snapshot with the latest version of the relation. For example:

// query

def changed[:added](x...) = t(x...) and not t_snapshot(x...)
def changed[:deleted](x...) = t_snapshot(x...) and not(t(x...))
def output = changed

Note that this gives more accurate information about what has actually changed in t, compared to looking only at insert and delete.

## Integrity Constraints

Recall that integrity constraints are evaluated after all deletes and inserts are applied. If an update violates an integrity constraint, the violation is reported and the entire transaction fails. Integrity constraints can therefore ensure that properties of the database are maintained by any update. See the Integrity Constraints concept guide for more details.

For example, you can make sure that a relation contains only integers with:

ic p_int { forall(x: p(x) implies Int(x) ) }

You can ensure that a relation is never empty by installing the constraint:

ic p_nonempty { not empty(p) }

As the diagram in the Transactions section shows, integrity constraints are checked after all the updates are applied, and before the transaction commits. Thus, for example, the p_nonempty IC will not be triggered if, in the same transaction, you can delete all the elements of p and then insert a new one:

def delete[:p] = p
def insert[:p] = 1

You can disallow all inserts or deletes with this integrity constraint:

ic readonly_database { not exists(x...: insert(x...)) and not exists(x... : delete(x...))}

## Recursive Inserts and Deletes

The insert and delete relations can be defined recursively, to handle “cascading updates,” where an update can depend on previous ones. For example:

def insert[:ancestor](x, y) = parent(x, y)
def insert[:ancestor](x, y) = parent(x, t) and insert[:ancestor](t, y) from t

This populates an ancestor base relation, starting with the existing parent relation, and then recursively adding new pairs if the inserts imply it. See the Recursion concept guide for more details on recursion in Rel.

As another example, assume that you have several products. You have a binary relation part_of(x, y), where x is a component of y, and that you want to mark products as imported if one of their parts is imported. Given a new_import fact, you can then update:

def insert[:imported](x) = new_import(x)
def insert[:imported](y) = part_of(x, y) and insert[:imported](x) from x

Note that this only updates the imported relation for products connected to the new_import fact.

## Other Notes

### Listing Base Relations

The SDK APIs allow you to list all installed base relations. For example, see this section of the RelationalAI SDK for Julia.

Creating both derived relations and base relations with the same name is not allowed. For example, this will fail:

def insert[:r] = {1; 2}
def r = 3

Like derived relations, base relations can be overloaded by arity and type. If you insert different types or arities into the same relation name, overloaded versions of the relation will be created:

// update

def insert[:q] = 3.0
def insert[:q] = "a"
def insert[:q] = (1, "b")
def output = q

## Summary

Updating data in a RAI database using the Rel language depends on changing, adding, or deleting either the base relations — the raw data — or the rules that define derived relations. The reserved relations insert and delete can be used in base relations to add or remove data. They are also used to load and replace CSV and JSON files. Rel also allows you to implement reactive data logic, use auxiliary base relations to update bugs, and even recursively define insert and delete relations to handle updates that depend on previous transactions.