HNHacker News
TopNewBestAskShowJobs

MatteoFrigo

672 karma · joined July 4, 2021

submissionscomments
MatteoFrigo··on Algorithms for division: Using Newton's method
Thanks!

Do you happen to know how these algorithms are implemented? Intel used to implement some variant of long-division (likely SRT), which takes O(n) cycles to divide two n-bit numbers. The Conroe numbers that you are quoting are consistent with an O(n) algorithm that processes two or perhaps three bits at each step.

However, the Zen 3 numbers that you quote are not consistent with an O(n) algorithm, but they are consistent with O(log n) steps of Newton-Raphson. Basically, do whatever you want to compute the single-precision answer in 10 cycles, and spend 3 cycles on one FMA to extend the result to double precision. Could it be that AMD is in fact implementing Newton-Raphson exploiting its 3-cycle FMA?

MatteoFrigo··on Algorithms for division: Using Newton's method
> I doubt Newton-Raphson gonna help much, if at all.

FWIW, in some machines in the past, division was implemented via Newton-Raphson and there was no other division hardware available. The implementation was either done in software or in microcode. The same statement applies to square roots as well.

The foundational technical result (due I think to Peter Markstein but I can't find the paper right now) is that a sequence of 4 (or 5?) fused multiply/add instructions produce a correctly rounded division (or square root) in double precision. The fused part is essential: you must implement ab+c with a single rounding at the end, because if you round after ab the final result is no longer exact in all cases.

Fused multiply/add instructions (FMA) were pioneered by the IBM RS/6000 and its Power/PowerPC descendants, and were adopted by Itanium, MIPS, and later x86/arm. IIRC, Itanium had no division instruction at all, and the compiler would generate the 4 (or 5?) FMAs for you, properly pipelined. PowerPC had a division instruction that would use the FMA unit multiple times.

The last time I looked into this problem (in 2005 or so) there wasn't much latency difference between FMA-based implementations and a dedicated hardware divider. I don't know what tradeoffs people are making these days.

MatteoFrigo··on Low interest rates in advanced countries have pushed money into real estate
This was in the news recently: CalPERS (a giant pension fund of California state employees) is going to add risk in the form of 5% leverage. See https://www.pionline.com/pension-funds/calpers-adds-5-levera...
MatteoFrigo··on Paxos automatically determined safe and secure
Hmm... how does it work? Say I finish the view change and then everybody loses power. When the power comes back, how do you know what the old view was? What prevents two distinct nodes from being both leaders of view v+1 (one before the power loss and one after power comes back) thus issuing inconsistent messages?
MatteoFrigo··on Paxos automatically determined safe and secure
> what if all nodes have a single disk sector error in different places on disk?

Well, there are many ways to skin this particular cat, but pretty much all large-scale storage systems (think S3) use some kind of erasure coding. That is, the replication protocol replicates a "log" whose execution generates a "state" of the "state machine". The log is fully replicated, but the state is erasure coded. This scheme tolerates single-sector errors in the state. If you have an error in the log you throw away the entire replica, but since the state is 1000x larger than the log, this is not a big deal.

At the end of the day the disk must guarantee something, or else you are screwed no matter what. For example, if an acceptor acknowledges a phase-1 (view change) message but the disk lies about storing the new ballot/view/term, then all these protocols are incorrect.

MatteoFrigo··on Paxos automatically determined safe and secure
TLA+ is a specification language. Its goal is to say exactly what the algorithm is, because an informal description in English or even pseudo-code is usually too ambiguous and not amenable to mechanical proofs. TLA+ by itself does not prove anything. You can write incorrect algorithms in TLA+, in the same way that you can write incorrect C programs.

Once you have a TLA+ specification, lazy people like me run the specification through a tool called TLC that exhaustively explores all possible behaviors of the algorithm in a finite search space. For example, the specification may say that a property is valid for all N, but TLC checks it for N=1, 2, and 3. This step is not a "proof" (it's more like a test suite), but people like me say "good enough" and ship at this point.

Lamport and colleagues have a tool called TLAPS where you can write a proof yourself (e.g., valid for all N), and the tool checks that the proof proves what it claims to prove.

The next step, which is what this paper is all about, is to derive the proof automatically.

MatteoFrigo··on The Unvaccinated May Not Be Who You Think
> the record is something like 6 weeks, so multiple years would be quite the outlier.

You have to be very careful with this kind of informal statements, because probability is a tricky thing.

For example, assume that a vaccine has a probability P of causing long-term bad effects and that we observe historically that 1000 vaccines have no long-term bad effects. What can we rationally say about P? It would be tempting to conclude that P is zero or at least negligibly small (maybe 2^(-1000) or something). However, this cannot be the correct answer because if P were 1/1000, you would observe the historical pattern with probability .999^1000 ~= 1/e, or about 1/3 of the time. A more sophisticated analysis would conclude that it is very likely that P is somewhere between 0 and 2/1000, and if you believe a thing called the "Laplace Rule of Succession", the expected value of P is something like 1/1002.

Now, 1000 widely deployed vaccines sounds like a reasonable upper bound to the number of vaccines ever produced, which would suggest that the probability of this vaccine being safe is probably 100% but the error bar is O(1/1000). O(1/1000) is about the same as the probability of the virus killing me, so it is perfectly rational to have doubts.

MatteoFrigo··on Covid lesson: trust the public with hard truths
I am sure that "the people" had good intentions. However, you can be sure that the sociopaths running the show knew perfectly well what they were doing. It's not like Mao wanted to save the people from oppression and ended up screwing everybody by mistake.
MatteoFrigo··on Amazon will allow many employees to work remotely indefinitely
Please be aware that Amazon will insist on a non-competition agreement. Depending on your seniority level and whether such agreements are enforceable in your jurisdiction, there is a high chance that this will limit your opportunities after you leave Amazon. Don't overlook this aspect when evaluating offers.

This is an example of how this interferes with the career of a very senior executive: https://www.geekwire.com/2021/microsoft-standoff-amazon-big-... However, this problem also affects junior engineers, more junior than you may think.

MatteoFrigo··on NYT Rectracts Number of Children Hospitalized by Covid-19 (From 900K to 63K)
The CDC disagrees with you. Go to https://www.cdc.gov/nchs/nvss/vsrr/covid19/excess_deaths.htm... and click on "Weekly Number of Deaths by Age". There is no observable difference in the 0-25 age group between 2020, 2021, and the previous years.

The equivalent data for Europe are at https://euromomo.eu/graphs-and-maps, which I find easier to use. You will see that the excess mortality in the 0-14 age group is actually negative in 2020 and marginally positive in 2021 so far (went down a bit earlier in the year and now is back up a bit).

MatteoFrigo··on Pfizer vaccine immunity diminishes, can reach as low as 20% after 4 months
I for one look forward to OP's submissions, and I am perfectly capable of forming my own opinion on the quality and content of each one.
MatteoFrigo··on Finland joins Sweden and Denmark in limiting Moderna Covid-19 vaccine
Cumulative numbers since the beginning of time are kind of meaningless to evaluate risk, though. They can be useful to assess the damage when all is said and done, but risk is about the future and not the past. Also, probabilities should be per unit time, otherwise they go up forever by definition.

I think a better assessment of risk comes from the UK data https://assets.publishing.service.gov.uk/government/uploads/...

From Table 3, we learn that somebody unvaccinated in their 20's has a chance of 10/100,000 to end up in the hospital over a period of 28 days. So something like .1% per year. Vaccination reduces the risk by a factor of O(10), old age increases it by a factor of O(10). These data refer to a recent snapshot of a 28-day period, and I'd feel safer to assume that the next month looks more like the previous month than March 2020.

MatteoFrigo··on Covid-19 Lockdown Cost/Benefits: A Critical Assessment of the Literature
Very interesting reading, thanks for posting.

Irrespective of whether or not the paper is correct, it is a great catalog of all costs and benefits, and of all the errors that naive models have committed.

MatteoFrigo··on Conterintuitive facts in mathematics, CS, and physics
The list is missing one of the most astonishing discoveries of all time: if you reflect the universe in a mirror, you can tell whether you are in our universe or in the mirror because the laws of physics are different in the mirror. See https://en.wikipedia.org/wiki/Wu_experiment
MatteoFrigo··on Merck says research shows its Covid-19 pill works against variants
> Many people who are vaccine skeptics are also living under the delusion that they aren't likely to get COVID. Or they believe if they do, it will be mild. If they do get it and it turns out not to be mild, then they are much more likely to be willing to try an "experimental" treatment.

You say it as if it were a bad thing, but competitive algorithms are a perfectly valid approach to many problems, including this one.

Consider the following parable. A village in the Middle Ages is harassed by a dragon, which demands one gold coin in tribute per day. The villagers can either pay the tribute every day, or give 50 gold coins to a knight who will slay the dragon. The dragon is old and may die any day, at which point they don't need to pay the tribute, but nobody knows the future. What are the villagers supposed to do?

One way to proceed is for the villagers to estimate the probability of the dragon dying on each day, and build a strategy that minimizes the expected expense. Another way to proceed is the "competitive" algorithm: pay the tribute, and if the dragon is still alive after 50 days, hire the knight. This strategy minimizes "regret", defined as the ratio between what you actually do and what you could have done had you known the future in advance. (For this strategy the regret is 2. A more complicated strategy exists with regret e/(e-1).)

These kind of decisions happen all the time in life. I worked at a company whose attitude was, effectively, ship now and we'll fix bugs only after the first outage. (This is the competitive algorithm.) I also worked at a company that tried to predict in advance all possible problems that may arise in the next ten years, thinking that this strategy would lead to better long-term results. Both were successful, though I think the competitive approach was more successful in the specific domain I was working on.

My point is that the strategy that you describe could be motivated by ignorance, but it could also be motivated by a pretty sophisticated understanding of the world.

MatteoFrigo··on YouTube is banning anti-vaccine activists and blocking all anti-vaccine content
One thing that is hard to quantify is the risk of long-term effects, which are unknown.

There is an elegant argument, due to Laplace, that says that if you have an urn containing red and blue balls, you extract N balls, and M of them are red, you should assume that the probability that the next ball is red is (M+1)/(N+2), and not M/N as one might naively assume. The general case requires integrating the beta function, which is kind of advanced, but the M=0 case can be done with elementary calculus, as follows.

Call X the probability of extracting a blue ball, which we view as a property of the urn. If we don't know anything about X, before we extract any balls, we should assume a uniform prior distribution P[X]=1 for 0<=X<=1 (this is the main and only assumption). The probability of seeing M=0 red balls after extracting N, for given X, is the same as the probability that all balls are blue, i.e., P[M=0|X]=X^N. But we care about P[X|M], not P[M|X]. By Bayes' theorem, P[X|M] is proportional to P[M|X]P[X], times a proportionality constant that makes the total probability be 1. Because we assumed P[X]=1, we have that P[X|M=0] is proportional to P[M=0|X]=X^N. The integral of X^N between X=0 and 1 is 1/(N+1), yielding P[X|M=0]=(N+1) X^N. The expected value of X is the integral for X=[0,1] of X P[X|M=0], which is E[X]=(N+1)/(N+2). This is the expected probability of a ball being blue, with 1-E[X]=1/(N+2) being the probability of a ball being red. QED.

Now say we have historically observed 1000 vaccines and they were all safe in the long term. It is still perfectly rational to assume that there is a 1/1002 chance that this vaccine is unsafe in the long term. Anybody claiming otherwise better have a cogent argument about why the prior probability should not be uniform. Saying that 1000 vaccines were long-term safe and thus this one is long-term safe is equivalent to assuming a prior of the form P[X]=1/(X (1-X)), which is hard to justify (and diverges at 0 and 1).

Basically, the problem is that we are entering the territory where the risk from the disease is comparable to a rational estimate of the risk of what we don't know, and it's hard to come to any kind of cogent conclusion.

But anybody who claims that all past vaccines were long-term safe and thus this one is long-term safe clearly does not understand basic probability.

MatteoFrigo··on U.S. Adults' Estimates of Covid-19 Hospitalization Risk
I don't know where you are getting your "correct" answer, but the numbers you are reporting don't seem to agree with reality.

For example, recent data from the UK https://assets.publishing.service.gov.uk/government/uploads/... shows [Table 2] that the probability of a case given {vaccinated, unvaccinated} is within a factor of 5 of each other (in fact, for some age groups, the probability of being a "case" is higher for the vaccinated). Also, the probability of being hospitalized is within a factor of 10 between the two groups for all ages [Table 3]. There is no way to get the three orders of magnitude difference that you quote given these figures.

> why are Americans overwhelmingly flat out wrong on this statistic?

Speaking for myself, if somebody called my phone out of the blue to ask me a stupid question (are you republican or democrat? what's the probability of hospitalization?) I would make up an answer just to troll them. I would probably mention Bill Gates' chips as well. What's my incentive to tell the truth, given that I believe that all polls and media are a bunch of liars?

MatteoFrigo··on [dead]
> In Alabama, there have been more Covid deaths than births.

All sources I have seen report that Alabama had more total deaths than births in 2020, i.e., population went down. (This is the normal state of affairs in many countries, even without covid) E.g., nytimes (https://www.nytimes.com/2021/09/18/world/covid-alabama-death...) says 58k births, 65k deaths of which 7k due to covid.

Do you have different information?

MatteoFrigo··on FDA panel recommends Pfizer's Covid booster doses for people 65 and older
Wonderful triply-nested trolling, thanks for the laugh!
MatteoFrigo··on FDA panel recommends Pfizer's Covid booster doses for people 65 and older
CNBC updated the headline after the fact.

The panel initially voted to reject the booster. Afterwards, they held a second vote in which the panel approved the booster for 65+.

MatteoFrigo··on FDA panel recommends Pfizer's Covid booster doses for people 65 and older
Aside from the specifics of the case, the contrast of headlines is interesting. CNBC says "FDA panel rejects ...". Bloomberg says: "FDA Advisers Back a Narrower Authorization for Pfizer Booster"

Reminds me of an old Soviet-era joke. Ronald Reagan and Leonid Brezhnev race the 100 meters, and Reagan, being much younger, wins the race. Headline in the Pravda: "Brezhnev places second, Reagan second-to-last".

MatteoFrigo··on Deaths involving Covid-19 by vaccination status, England
You can read the report, but the blood donor population is 17 years or older.

The result of the report is that some form of immunity exists in 97%+ of the blood donors at least 17 years old, in the UK.

MatteoFrigo··on Deaths involving Covid-19 by vaccination status, England
The PHE report measures both antibodies from natural immunity, and antibodies from (vaccine or natural infection or both). (They don't have a vaccine-only measure.) The former is in the 20% range, depending on age. The latter is in the 97%+ range, again depending on age, reaching essentially 100% for older people.

The big caveat is that the sample population consists of blood donors, which may or may not be representative of the overall population.

MatteoFrigo··on Ancient Greek ‘pop culture’ discovery rewrites history of poetry and song
> Until now, ‘stressed poetry’ of this kind has been unknown before the 5th century, when it began to be used in Byzantine Christian hymns.

FWIW, some scholars argue that the Roman Saturnian verse (3rd century BC or earlier) is stressed poetry. See https://en.wikipedia.org/wiki/Saturnian_(poetry) for examples.

MatteoFrigo··on Why Are So Many Young Men Giving Up on College?
Since I don't normally follow "white supremacists", and I would have a hard time finding them even if I wanted, how am I supposed to know what's a dogwhistle and what is not?
MatteoFrigo··on England vaccine passport plans ditched, health secretary says
You have the right to be unhappy. However, looking at the latest data from the UK at https://assets.publishing.service.gov.uk/government/uploads/..., it is not clear whether pushing for more vaccines will change the situation in any way that makes you happy.

For example, that report says that 97% of the blood donors has some kind of antibodies, either from vaccine or previous infection. This number is almost 100% for older people. Maybe blood donors are not representative of the population, but if they are, it's not obvious that the extra 3% buys you anything, even if you could capture it.

For some age groups (Table 4), the vaccinated are more likely to be infected than the unvaccinated. I am sure there are good reasons for this, e.g. people more at risk may be more likely to be vaccinated, but whatever the reason is, the vaccine does not seem to be powerful enough to compensate for the extra risk.

MatteoFrigo··on Show HN: Time Series of CDC's Covid-19 Vaccine Breakthrough Case Reporting
> if there is a stable probability, we might converge to it

Yeah, that's the thing I can't figure out from the literature. For example, people say that vaccine X is 90% effective. This means that they ran two groups for some number of weeks, and observed one tenth of infections in one group vs. the other. But what does this mean in terms of individual probabilities? Assume for simplicity that the vaccine immunity lasts forever without decaying. There are still two extreme possibilities consistent with the data, as well as multiple intermediate options. In one extreme, the vaccine sets an immunity bit in each individual, and the unlucky ones will get infected when exposed. In the other extreme, the vaccine somehow increases everybody's activation energy for infection so that, under normal conditions, the probability that an exposure causes an infection is reduced by a factor of 10. In the former case, the steady state is that 10% of the population gets infected eventually, and that's it. In the latter case, you keep going forever with infections per unit time being 10% of what they used to be.

MatteoFrigo··on Show HN: Time Series of CDC's Covid-19 Vaccine Breakthrough Case Reporting
Data from the UK can help with the decent guesstimate you are looking for. See https://assets.publishing.service.gov.uk/government/uploads/... pages 15--17. (The rest of the report is interesting too.)

The probabilities in the UK are clearly marked as probabilities per unit time, where the unit time appears to be four weeks. In contrast, it appears that the CDC data is cumulative since the Big Bang, which I think is less useful to your purpose.

MatteoFrigo··on Biden to mandate coronavirus vaccine for federal workers
Great document, thanks for the link.

The document says that >97% of the blood-donor population in the UK has some kind of antibodies, either from natural infection or vaccines. This seems like an astonishingly high number.

MatteoFrigo··on Ask HN: Is Google, as an employer, losing its prestige?
At the risk of going off-topic, I would remark that prestige is kind of meaningless and doesn't even fetch $1.99/lb on ebay. If you are asking this question because you are looking for a job, I would recommend following the gradient of your bank account and ignoring prestige. If the gradient of your bank account points to Google, good for you.
← PreviousPage 5 of 7Next →