need help understanding pytorch blitz math notation - pytorch

I just came across this notation in the pytorch blitz tutorial and I dont know what the vertical line is
Does anyone have any suggestions on the notation?

The vertical line means the value of the left side variable given that the right side variable is a particular value. So, your given example means z_i is 27 when x_i is 1.
Basically, it means 'LHS holds given RHS'

Related

How can I define a code using the Hamming algorithm?

I've got this request: Using any alphabetical and numerical symbols, define a code in which each symbol of interest is associated with the corresponding binary configuration. The code must use 5 bits, be redundant, and be characterized by a Hamming distance of 1. Identify the cardinality of the defined code. Eventually, does the code exist?
I don't have a clear idea about how to do this, could anyone help?
Thank you!

Can someone please explain the Ray-casting algorithm for point in polygon i.e. containment check?

Consider a polygon with two loops i.e. Outer loop& inner loop as shown in the images attached with this question(One can think of an English letter "e" for example). Can someone please explain how exactly the Ray-casting algorithm will work in such cases.? If possible, please put some images/drawings in answer, for better visualization and understanding.
Imagine a point moving from infinity to the target point along a straight line (will also work with a curve).
The point at infinity is outside the shape. Whenever an outline is met, you switch from outside to inside or conversely. This rule defines internal and external points. In the given case, the inside of the rounded rectangle, inner circles excluded.
Algorithmically, you count the intersections of the segments that define the shape with the half-line to the target.

Why is string interpolation named the way it is?

The term interpolation is usually used in mathematical functions when determining a function for given values, which makes perfect sense. I don't see how that applies for strings, what is being interpolated? Am I missing something obvious?
Interpolation in mathematics is simply working out the things between two points(a). For example, cubic spline fitting over a series of points will give you a curve of some description (I consider a straight line to be a degenerate curve here so don't bother pointing out that some formulae generate such a beast) between each set of points, even though you have no actual data there.
Contrast this with extrapolation which will give you data beyond the endpoints. An example of that is seeing that, based on history, the stock market indices rise at x percent per annum so, in a hundred years, will be much higher than they are now.
So it's a short step to the most likely explanation as to why variable substitution within strings is called interpolation, since you're changing things within the bounds of the data:
xyzzy="42"
plugh="abc${xyzzy}xyz"
// now plugh is equal to "abc42xyz"
(a) The actual roots of the word are Latin inter + polare, those translating to "within" and "polish" (in the sense of modify or improve). See here for more detail.

Dot Product - How does it help to define whether the light source hits my object or not?

For example the light source is coming from 1,3,-5 and object is at 4,-2,-1.
Algebraic formula is going to give the answer as 3. [1,3-5].[4,-2,-1]
= 1*4 + 3*-2 + -5*-1 = 3
But what does this 3 means? How do I know if my object is shaded with this number 3? Or is there more to it? I did look around and unable to find anything conclusive. Would be great if someone could give some insight. Thank you.
Judging from answers, pondering if I am understanding my question wrong. I was trying to get my head around the following question:
For a point on a convex surface, with the normal n=(n1,n2,n3)and light
direction l = (l1,l2,l3), determine if the point can be seen by light
source.
Using a dot product between two points makes no sense. Essentially, a dot product gives a measure of how similar two vectors are. When applied to points, the value will be related to the similarity of the direction to the points from the origin, as well as their distance from it. That metric doesn't make much sense, as you found out with that '3'.
To determine the amount of illumination, you want to be using a dot product between the normalized vector of the direction from the surface to the light and the surface normal. The result will be a value from -1 to 1, which you can interpret as an illumination factor for simple gouraud shading. In pseudocode:
illumination = max(0, dot(normalize(lightPosition - positionOnSurface), surfaceNormal))
Determining if a light hits an object is an entirely different problem called occlusion, and not really something you express in as mathematical formula. It's about testing what objects are in the path from the light to your target object.
The dot product can tell you on what side of a line a point is. The triangle is formed by three lines. If you are on the same side of all three lines then you are inside the triangle. You can use three dot products to test for each of the three sides. See slide 23 on this link http://comp575.web.unc.edu/files/2010/09/06raytracing1.pdf.

Calculating margin and bias for SVM's

I apologise for the newbishness of this question in advance but I am stuck. I am trying to solve this question,
I can do parts i)-1v) but I am stuck on v. I know to calculate the margin y, you do
y=2/||W||
and I know that W is the normal to the hyperplane, I just don't know how to calculate it. Is this always
W=[1;1] ?
Similarly, the bias, W^T * x + b = 0
how do I find the value x from the data points? Thank you for your help.
Consider building an SVM over the (very little) data set shown in Picture for an example like this, the maximum margin weight vector will be parallel to the shortest line connecting points of the two classes, that is, the line between and , giving a weight vector of . The optimal decision surface is orthogonal to that line and intersects it at the halfway point. Therefore, it passes through . So, the SVM decision boundary is:
Working algebraically, with the standard constraint that , we seek to minimize . This happens when this constraint is satisfied with equality by the two support vectors. Further we know that the solution is for some . So we have that:
Therefore a=2/5 and b=-11/5, and . So the optimal hyperplane is given by
and b= -11/5 .
The margin boundary is
This answer can be confirmed geometrically by examining picture.

Resources