Universal Method to Sort Complex Information Found
quantamagazine.org
quantamagazine.org
cosine similarity is [1,-1], so add one [2,0], now halve [1,0] now take logarithm [0,-inf] finally negate [0,+inf]
?
It does fail the triangle inequality, though, as the following python snippit demonstrates:
import numpy as np
def randomvec():
return np.random.rand(4)*2-1
def cossim(a, b):
return np.dot(a,b) / np.sqrt(np.dot(a, a) * np.dot(b, b))
def metric(a, b):
return -np.log((1+cossim(a, b))/2)
def main():
for i in range(20):
a = randomvec()
b = randomvec()
c = randomvec()
a2b = metric(a, b)
b2c = metric(b, c)
a2c = metric(a, c)
print a2b, b2c, a2c
if a2b + b2c < a2c:
print ' *** fails triangle inequality'
main()That's a kind of practical graph where you want efficient shortest path algorithms for.
In the US, on Amtrak, a ticket is specific to an exact train, like buying a plane ticket. There's no generalized "I want a ticket from DC to NYC."
You might have a major city, A, a center of finance and law and full of corporate headquarters, and a smaller city, B, where many of the companies whose headquarters are in A have their engineering and manufacturing facilities.
Someone making a deal with one of those companies may need to visit both engineering to work out technical details first and then visit headquarters to work out business, financial, and legal details. They will travel from home to B, and then travel to A, and then when done travel directly home from A. This may happen much more than the other direction--people needing to visit headquarters first and then going to visit engineering and manufacturing, without needing to go back to headquarters.
Net result: more passengers needing B to A than A to B. This can result in A to B trips having empty seats. It might even result in some trips with no passengers at all! They can't simply cancel those trips, because they need to get the vehicles to B to handle the B to A traffic, so they sell seats cheap.
This creates the asymmetry
But the most confusing part is the ring topology (here shown with the zone-ring center being the actual city center):
https://passagerpulsen.taenk.dk/sites/default/files/styles/f...
When buying 2-8 zones you don't pay for individual zones, but rather rings from your origin zone. Going one way, the zone rings look one way. Going back they look different, because the origin zone is different.
A practical example of this peculiarity:
You go from Hellerup (zone 2) to Friheden (zone 33) via the central station (zone 1). Your ring 0 is zone 2, and zone 1 and 33 are both in ring 1, so you only pay for two zone(-ring)s: https://dinoffentligetransport.dk/media/1413/svanemollen-fri...
You go back from Friheden to Hellerup via the central station: Your ring 0 is zone 33, zone 2 is in ring 1, but zone 1 is in ring 2 this time, so you pay for three zone(-ring)s: https://dinoffentligetransport.dk/media/1411/friheden-svanem...
Your origin zone on the way out was adjacent to both other zones needed (needing only 1 ring), but your origin zone on the way back was not (needing 2 rings).
So they're not just different prices: The graph that spans train stations via zones in the ring topology is not metric. So getting a return ticket is not the inverse of getting the ticket out. And while you have a ticket that's valid for the timespan of your return, it may not be valid for your return path.
There are several reasons why it ended up like this, and I don't know all of them.
But two reasons I can think of:
1) With the introduction of RFID-based commuter cards, the zone system was revised for traditional ticket types as well. It appears convenient that a price can always be determined by knowing the check-in point, the check-out point and the shortest path in the graph. Unfortunately, with the old ticket types, you have to perform the calculation instead.
2) It is the odd shape of zone 2 that causes some tickets to not work on the way back, even though the trip goes in a straight line. But for a large part of all trips, you only need zone 1 and 2, or zone 2 and zone (30, 31, 32, 33). Only the ones that start in zone 2, go through zone 1, go back into zone 2 and farther into another zone (or vice versa) have the anomaly. (Trips that actually bend can have this too, but it is slightly more intuitive.)
I know that something similar happens with airplane tickets but they get you with the luggage and with terms & conditions AFAIK.
How is it similar/different with train tickets?
You are not allowed to break a journey either, so a ticket inspector can spot a ticket for a longer journey at one end of the other. The multiple tickets ruse is more of a grey area.
Rules vary by train company and route. In general you cannot break your outward journey (except for necessary changes of train) but you can break your return journey.
Source: https://www.splityourticket.co.uk/info/fare-types.aspx
I've already dealt with the legality of split ticketing in another post.
start -> actual destination (stay on train) -> overshoot destination (get off) (get back on) -> (turn around; begin return trip) -> actual destination (get off) (get back on) -> start
?
Seems utterly unintuitive, and it probably is, but I am curious.
Part of the reason for all this is that the train system has been broken up into a collection of franchises. Some companies will then incentivise some journeys, and so the fare doesn't always reflect the time or distance of the journey being made. As a result you can find and exploit anomalies, but only if you're willing to spend the (sometimes considerable) time and effort.
For most tickets.
Some tickets, such as Advance and some Super-Off-Peak, have additional conditions. However, I do have a letter from a train company saying that they were wrong to have charged for an extra ticket, and wrong to have tried to start proceedings.
So breaking an outbound journey can be legal, and in such cases buying an over-length ticket is possible. It's circumstances like these that led in part to some of the specifics of the recent shake-up of the fare structures.
https://www.telegraph.co.uk/money/consumer-affairs/fare-spli...
https://www.bbc.co.uk/news/uk-england-19217111
and there are web sites which do split ticketing:
http://www.raileasy.co.uk/home/split-ticketing/
However, what can be in breach of the terms and conditions is to buy a ticket for a longer journey than desired and then get off at an intermediate station. If you read the comment to which you're replying, it's the "overlength ticket" that he is saying can be illegal.
A round-trip can be cheaper depending on direction of travel.
One-way trip can be significantly cheaper if you are flying through a major hub like FRA and starting your journey from a less wealthy country.
That would be a metric space, and a distance obey the triangle inequality by definition. The element of the space are otherwise quite arbitrary.
Unfortunately, Normed spaces are a subset of metric spaces which are much less general (in particular they have to be vector spaces).
Also, a math correction: spaces which obey the triangle inequality are called metric spaces. The class of normed spaces is more restricted, but still very large.
(Thanks for the correction. I just gave one of the properties, but should’ve been more precise.)
A graph G is a distance(k)-expander if #edges(U, V-U) > c min(#U,#(V-U)) where U is a set of diameter <=k. Now study the embeding.
I am also curious about what happens if one use SVM to classify vertices of an expander graph: Let G be an expander graph and let u1,u2 be vertices of G such that d(u1,u2) = diameter of G = an even number 2k. We classify the vertices of G like this: f(u) = 0 if d(u,u1)<=k, f(u)=1 if d(u,u1)>=1, then using SVM applied to the vertices encoded by the rows of the adjancecy matrix. I would expect the SVM algorith to have some special property but I don't know what to expect, the best or worst classification, or the support vectors can gives us some information about symmetries in the graph.
It's interesting that this is called Manhattan distance because it's only relevant in a town where everyone jaywalks... Like Manhattan. It's far from true anywhere where jaywalking is frowned upon.
Because of (the lack of) crosswalk synchronization, it's a lot faster to walk to a place 2 blocks over and 2 blocks up than it is to walk to a place 4 blocks in one direction. Because at the first two lights you have the option of crossing in either direction, at which point you may only have to wait a few moments before crossing in the other direction.
I had exactly the same thought about crossing streets when reading one of his books. Always choose a route where you have the choice to keep walking in some direction towards your destination, with a delayed jaywalk to cross to the side you want during a gap in traffic, rather than wait on a corner when a crossing is blocked. The reason for blockage can be a crosswalk light (if you obey them) or traffic itself - the rule applies even without any signal-controlled junctions.
There are currently a ton of mediocre ways to do this because nothing really works very well in high dimensions, and calculating this can easily be the bottleneck in training and evaluation.
Two problems that have to do with k-NN are
1. It's a non-parametric method: the number of parameters grow linearly with the size of the training set since the distance function must be calculated for all training points and the test point.
2. The curse of dimensionality: distance metrics like the Euclidean distance do not perform well in higher dimensions; points which seem "close" in 2D may be far in 3D, 4D, etc. As a result, we would need an exponential amount of more training data for every additional dimension. Locality sensitive hashing tries to combat this by reducing the dimensionality of the data.
Edit: The author says its https://ilyaraz.org/static/papers/daher.pdf, but he got marked dead by HN.