home | services | products | resources | forum
 
about us | contact   
Particle
September 19th, 2018



www.theparticle.com
Main
Services
Products
Resources
Forum
About Us
Contact

Particle Revelation
Hardware Destruction
Quotes
Humor [alpha]
Murphy's Laws

Programming
Java
Java Data Structures
C# Data Structures
Database Design
Graphics Tutorial
Artificial Intelligence

Downloads
SQLRunner
Graphics Tutorials
Hacking Tutorials
Java Applets
MIDI Music
Gov & Misc Docs

Games
Chess Game
Asteroids
Tic-Tac-Toe
Tetris

Applets
DRAW!
FlightBox
pWobble 3D
pRunner
NYU HWs
Swarms
Geometry
Chaos
Machine Learning

Academic
CISC 7700X
CISC 7510X
Net (old)
OS (old)
AI (old)
App Dev (old)
C++ (old)
OOP (old)
Web (old)
Perl (old)
DBMS (old)
Perl (old)
ProgLangs (old)
PHP (old)
MltMedia (old)
Oracle (old)

Misc
Privacy Policy
Publications
profphreak.com


www.theParticle.com
Welcome to www.theparticle.com. It's the newest pre-IPO dot bomb that's taking the world by storm. Now is a perfect time to buy lots of worthless and overpriced shares!
     What this site is about?

Internet is becoming more and more polluted with junk-mail, people selling crap, and businesses which don't know their place on the net. They're all trying to make this wonderful place (i.e.: the net) in to hell (i.e.: real world). Internet should be viewed as a place of imagination, creativity, and most of all: fun. Internet is not some really advanced tool for searching for people to rip-off. It's about searching, and finding, things which are useful, helpful, and promote the sharing of ideas. This is what this site is striving to become.

News, Updates, & Rants...

     September 15th, 2018

Re-subscribed to World of Warcraft for a bit (pre-ordered the expansion, but haven't logged in yet).

- Alex; 20180915
September 15th at wikipedia...

     August 31st, 2018

Went to doc for the knee. Did X-ray, and ``nothing serious''. Still hurts though. Scheduling MRI :-/

- Alex; 20180831

     August 24th, 2018

Think last week's hike hurt my knee. It's been bothering me since the hike, today more than before :-/

- Alex; 20180824

     August 23rd, 2018

Crazy thoughts: been thinking about connection between n-tuple method and quantum mechanics. If we make n large (in n-tuple) then we get more precise results, but less generalization. If we make n=1, then we get average behavior. The link to quantum mechanics is that if we're only working with one quantum system, we get average behavior, but if we're working with many particles, we get some sensible predictable power. (e.g. we can predict how masses will fall down to earth because they're made up of many many particles... but at individual atom level that's hard... same for n-tuple method, we can do prediction based on a large n-tuple, but if n=1 then prediction only goes as far as overall average).

- Alex; 20180823

     August 19th, 2018

Hicking up Mnt.Washington. 3-hours up via Boot-Spur trail, 1-hour on top (loop around Lake, and upto summit building, and 2-hours down via Lion's Head trail.

Much of the Tuckerman trail is actually closed, and there's a detour via a VERY steep road that just seems to go up up up (or down-down-down). It's shorter than the trail, but it's much harder to walk down on.

- Alex; 20180819

     August 18th, 2018

Driving out to Mnt.Washington.

The mountain is all foggy. Drove upto summit, and there's no view. Very cold and wet :-/

At the fancy hotel, Suneli found a bullet under one of the shelves.

- Alex; 20180818

     August 17th, 2018

Finished reading The Three-Body Problem by Cixin Liu, Ken Liu (Translator). This book is... well... different. It's very very good.

Sometimes a book has quite unique concepts and a story. Kind of like Einstein's Bridge by John Cramer. The Three Body problem is kind of similar... very deep and unique SciFi.

Definitely recommend.

- Alex; 20180817

     August 15th, 2018

Kiddo doc appointment day. Leaving early for the 8am appointment. As merging into LIE, right past exit 19, was changing lanes, checked the side mirror and blind spot, and at that instant the car ahead of me suddenly stopped.

Noticed it a bit too late. Slammed on break, and still rolled into the back. My front bumper got cracked, and the other car's metal bumper protector got damaged (no damage to the car itself). My bumper got fixed after a kick (it got a scratch on it now, but besides that, it's all good).

Pretty scary experience. Blocked two lanes on the LIE that morning (until it became apparent that this wasn't anything major). The other driver didn't speak english, so didn't understand me when I was asking whether I should call emergency. The cops never showed up. A passing-by state trooper stopped traffic and let both of us drive onto the shoulder.

Missed kid's doc pointment :-/

- Alex; 20180815

     August 6th, 2018

...and back in New York :-)

- Alex; 20180806

     August 5th, 2018

Back to Ambala, and then drive to Delhi airport.

- Alex; 20180805

     August 4th, 2018

Feeding cows at a cow sanctuary :-)

Getting to Noor Mahal Hotel, and enjoying swimming pool.

- Alex; 20180804

     August 3rd, 2018

Taking morning commuter train from Ambala Cantt to Chandigarh.

Visiting Chandigarh rose garden, and having cheesecake at Elante mall.

- Alex; 20180803

     August 1st, 2018

Morning mini-hike to Jakhoo temple.

Driving back to Ambala.

- Alex; 20180801

     July 31st, 2018

Driving to Shimla.

- Alex; 20180731

     July 28th, 2018

Landed in Delhi. Driving to Ambala.

- Alex; 20180728

     July 27th, 2018

Flying out to India.

- Alex; 20180727

     July 24th, 2018

Does Microsoft Surface Go tablet come with a prorprietary charger? (e.g. does it use USB-C for power like every other modern tablet these days, or does it require its own proprietary power adapter?).

In other news, a friend flying on Hawaiian airlines discovered that I'm mentioned by name in an in-flight magazine, in a story about Mauna Loa. ``Hona Hou!'' magazine, June/July 2018, Volume 21, No. 3. page 90 :-)

- Alex; 20180724

     July 20th, 2018

Given these numbers:
[50, 16, 5, 54, 1, 92, 42, 20, 63, 19, 29, 17, 75, 98, 99, 83, 84, 69, 8, 27, 71, 65, 30, 73, 69, 54, 37, 63, 46, 85, 54, 45, 36, 35, 93, 14, 26, 91, 22, 23, 0, 12, 58, 98, 34, 75, 51, 44, 61, 56]

The mean is: 49.44.
The mean of the first 20 is: 47.550.
The mean of the last 20 is: 48.238.
Mean of every even index is: 45.76, and odd indexes 53.12.

If we randomly pick out 20 numbers, what do you think the mean will be? Yep, about 50-ish.

With that in mind, we can estimate any integral (sum) by randoly sampling a few numbers.

- Alex; 20180720

     July 19th, 2018

Future Value = Present Value * (1 + rate)

If rate is 0.045 a year (4.5%), then the future value of $100 in a year is $104.50.

It works in reverse too. Present Value = Future Value / (1+rate).

A $100 a year from now is worth: 100/(1+0.045) = $95.694

If we raise (1+rate) to a power, we can calculate it over many years. e.g. A promise to pay $1000 in 18 years at 4.5% a year is worth: 1000/(1+0.045)^18 = $452.80 in today's dollars.

What rate would we need to turn $100 into $1000 over 18 years? We can solve for rate:
rate = (Future Value / Present Value)^(1/years) - 1
or (1000/100)^(1/18) - 1 = 0.13646, or 13.65%

We can check that, 100*(1+ 0.13646)^18 = $999.94

How many years would we need to get $100000 if we start with $1000 and expect a rate of 8% a year?

years = (log(future value) - log(present value)) / log(1+rate)
or (log(100000) - log(1000)) / log(1+0.08) = 59.838 years.

So far, we looked at interest that's compounded annually (the interest is added at the end of the year). What if it's compounded 4 times a year? Then the future value of $100 a year from now (at 4.5% interest) is:
100 * (1+0.045/4)^4 = 104.58, or
Present Value = Future Value / (1+rate/n)^n
where n is the number of compounding intervals.

Notice that 104.58 is greater than 104.50 we got before. So more frequent compounding makes more money. What if we compound continuously... like every nanosecond... (let n go to infinity). We get:
Future value = Present value * exp(rate * time)
where time is in years.

The future value of $100 a year from now (at 4.5% interest) is then
100 * exp(0.045*1) = 104.60

This works in reverse too... What's the present value of $5000 five years form now?
5000 / exp(0.045 * 5) = $3992.6

- Alex; 20180719

     July 18th, 2018

Berkshire has lifted restrictions on what they'd consider a fair price to buy back shares. Stock poped by 5%. Before, the limit was 1.2 book value: if share price fell below 1.2 times book value, the company would buy back their own shares. Now the limit is anyone's guess; perhaps 1.5 book value?

In either case, a company buying back shares is pretty ugly business. On one end, if the executives are doing it because they think they're cheap, then they're taking advantage of the shareholders (by using their own money to buy them out).

On the flip side, if executives are doing it irrelevant of the price (e.g. 1.5 book value maybe), then they're disadvantaging the existing shareholders buy overpaying the infated share prices.

So either case, the company is acting bad towards its shareholders.

With that in mind, it's more likely the company is buying them back because they're underpriced...

- Alex; 20180718

     July 17th, 2018

If we wanted to multiply two 2 digits numbers, AB * CD, we could start by changing the representation of the numbers... e.g. AB is actually A*10+B, and CD is actually C*10+D.

So to multiply AB*BC, the result is actually
(A*10+B) * (C*10+D) =
A*C*100 + A*D*10 + B*C*10 + B*D =
A*C*100 + 10*(A*D + B*C) + B*D =
x*100 + y*10 + z

where x=A*C, y=A*D+B*C, and z=B*D

There are several ways of computing A*D+B*C. First observe that
x+y+z = A*C + A*D+ B*C + B*D = (A+B)*(C+D)

So to get A*D+B*C we can just take (A*C + A*D+ B*C + B*D) - A*C - B*D, leaving only A*D+ B*C. We already have A*C and B*D calculated, as x, and z respectively. In other words:

y = A*D+B*C = (A+B)*(C+D)-x-z

The A*D+B*C has two multiplications, while (A+B)*(C+D)-x-z has one multiplication. So the total AB*CD multiplication can be done with 3 multiplications, and not 4 as in grade school algorithm.

And this can be used recursively for numbers that are bigger than 2 digits.

The above is known as the Karatsuba algoritm, and apparently it was invented in 1960.

- Alex; 20180717

     July 16th, 2018

If computer programming can be absracted away into implementing predicates, then every program is essentially defining a set of numbers.

In other words, { x | is_even(x) } defines a set of even numbers. There's a predicate is_even that defines this set. In previous rant (7/13) we've seen that any program (particularly those that return a numeric result) can be implemented as one that outputs a 0 or 1 value.

So every computer computer program defines a set.

Now, lets take the set of integers, and take a power set of it. What we get is a set of all subsets of all integers.

Looking back at the predicate view, each of these subsets is esesntially juset a binary number, indicating presense or absense of a value.

For example, is_even(x) may be represnted as:
010101010101010101010101010101010101010101...

Is divisible by 3 may be:
001001001001001001001001001001001001001001...

And divisible by 7 as:
000000100000010000001000000100000010000001...

We can combine them via:
010101010101010101010101010101010101010101... even
001001001001001001001001001001001001001001... divisible by 3
000000100000010000001000000100000010000001... divisible by 7
....
....

We can make this list as long as we want. count in binary.

Now take diagonal elements, and flip them: [1]10101010101010101010101010101010101010101...
0[1]1001001001001001001001001001001001001001...
00[1]000100000010000001000000100000010000001...
....

Now, no matter how how many sets we've listed, the set represented by this diagonal isn't on the list... (this is called diagonalization).

In our case, it shows that there are subsets (or mappings) that cannot be represented by predicates. So the mappings/sets exist (superset of all integers has that diagonal set), but we cannot have a predicate define that set.

What kind of sets cannot be defined by predicates (computer programs). One of them is the halting program. In fact, there's an infinite number of such sets that cannot be defined by a program.

- Alex; 20180716

     July 13th, 2018

Normally computer problems are seen as turning inputs into outputs, where output can be any number.

For example, square function would take a number and return its square.

Also, inputs and outputs are arbitrary numbers (if the input is a file, then the input number is the contents of the entire file). Same for output.

Godel came up with a way to map list of numbers into a single number: lets say we wanted to represent list 45, 2, 23, 0, 5 as a number, we could take 2^45 * 3^2 * 5^23 * 7^0 * 11^5. Note that we can represent any list of numbers as a single number (by doing powers of the prime factors).

So computer programs map numbers to other numbers. Number in, number out.

What if we're limited to programs that can only output a single bit as input. In logic these are called predicates. Number in, 0 or 1 out.

Are those programs just as powerful as those that can produce any number as output?

For example, can we build a function such as square using nothing but functions that return one bit? Obviously we're allowed to call our predicate program multiple times.

So let us setup a predicate that looks like: is_square_over(x,n){ if(x*x > n) return true; return false;

How can we use this predicate to calculate square of x?

The simplest approach is to do a for loop, for(i=0;;i++) if(is_square_over(x,i)) return i-1;

But this for loop doesn't scale. If someone asks for square of 1000000 we would be looping for 1000000 times, while the square calculation is much simpler than that.

The trick is to find the uppwer bound on the output. Lower bound is already 0, the upper bound can start at 2, and then doubled until the predicate returns false.

Once we have the lower and upper bounds, we can do a binary search for the last instance where predicate returns false. It would look something like this:

sub square {
 my ($x) = @_;
 my $h = 1;
 while(is_square_overN($x,$h)){
  $h *=2;
 }
 my $l=int($h/2);
 my $cnt = ($h+1) - $l;
 while($cnt > 0){
  my $step = int($cnt/2);
  my $it = $l + $step;
  if(is_square_overN($x,$it)){
   $l = $it + 1;
   $cnt -= $step + 1;
  }else{
   $cnt = $step;
  }
 }
 return $l;
}

Peformance wise, the square implementation using the predicate isn't that much slower; factor of log difference.

- Alex; 20180713

     July 12th, 2018

We sometimes hear of folks writing programs to generate first N digits of pi. Where N is a million, etc. It seems we can write programs to produce digits of pi: If left running forever, it will produce correct digits of pi for as long as it's running. If left running forever, it will produce pi.

Now, given this program (in a black box), can we write another program to verify that it truly does produce pi? The verification program would need to generate its own digits of pi, and compare them against the output of the black box program. If it finds a wrong one, it returns false. But will it ever return true?

This is just another variation on the halting problem.

But what if the verification program just returns "no". Will it be correct?

Consider that the box is finite (there's only so many bits it can hold). Eventually any finite machine must fall into a loop---so any finite box that spits out digits of pi will eventually fail on some digit. Even a black box the size of the universe will not produce pi. So it's safe to return "no".

- Alex; 20180712

     July 10th, 2018

Uh, oh!

- Alex; 20180710

     July 5th, 2018

Hmm...

- Alex; 20180705

     July 3rd, 2018

Kiddo getting MMR vaccinations.

- Alex; 20180703

     June 29th, 2018

that's one hot day...

- Alex; 20180629

     June 17th, 2018

Walking all over in Canada. Apparently they have fireworks every friday and saturday.

Played in the hotel pool---kiddo loves the pool.

...and driving home :-)

- Alex; 20180617

     June 16th, 2018

Driving out to Niagara Falls; going to the Canadian side.

- Alex; 20180616

     June 14th, 2018

Finished reading Right From The Start: Taking Charge In A New Leadership Role by Dan Ciampa, Michael Watkins. This one is pretty good---especially the last few chapters/sections. The middle of the book is kinda bland, the start is ok, and the end is pretty good.

- Alex; 20180614

     June 11th, 2018

Uh, oh!

- Alex; 20180611

     May 25th, 2018

Ok, so I was wrong on the cause of the Uber crash: Uber's Self-Driving Car Saw Pedestrian 6 Seconds Before Fatal Strike, Says Report.

[relevant dilbert].

- Alex; 20180525

     May 24th, 2018

Finished reading The First 90 Days: Proven Strategies for Getting Up to Speed Faster and Smarter by Michael D. Watkins.

- Alex; 20180524

     May 14th, 2018

Finished reading AWS: Security Best Practices on AWS: Learn to secure your data, servers, and applications with AWS by Albert Anthony. This is essentially a list of AWS tech that are key to securing data on AWS. Every corp planning to move to AWS should do this stuff.

- Alex; 20180514

     May 11th, 2018

Finished reading HBase Design Patterns by Mark Kerzner, Sujee Maniyam. Pretty good non-very-technical book. Doesn't have anything too new (HBase: The Definitive Guide is way better).

- Alex; 20180511

     May 9th, 2018

Windows Notepad fixed after 33 years: Now it finally handles Unix, Mac OS line endings. Wow! Though I hardly use Windows, this does annoy me often enough for me to get excited about it.

- Alex; 20180509

     May 7th, 2018

So on March 20th, 2018, I speculated about the cause of the Uber self-driving car hitting a pedestrian... and now it turns out I was right: Uber crash reportedly caused by software that ignored objects in road.

In other words, there *are* things on the road that the car is *designed* to ignore.

- Alex; 20180507

     May 5th, 2018

Spent the morning watching the Berkshire Hathaway annual meeting.

Kiddo is 6-months today :-)

In other news, the reinforcement (or boosting) logic on top of the n-tuple classifier: Apparently the performance curve flattens out... Running on EMNIST, after 100 training iterations, for n=10, using 32 tables gets us 92% accuracy, using 64 tables gets us 94% accuracy, using 128 tables gets us 94.6% accuracy, and using 256 tables gets us 95% accuracy. And then it just flat lines. I'm sure the code can be pushed to get 96% accuracy, perhaps by using bigger n, or using more tables, but it seems it's just not worth it.

So back to the idea land...

- Alex; 20180505

     May 4th, 2018

Finished reading The Structure of Scientific Revolutions by Thomas S. Kuhn. Pretty neat book. Essentially a bit of change in perspective on the clarity and correctness of science. Text books record only theories that survived the test of time, giving an impression that these theories and ideas behind them had a very structured progression. Reality is often much more disjointed and unpredictable than that.

- Alex; 20180504

     April 30th, 2018

Starting new job today :-)

- Alex; 20180430

     April 29th, 2018

Implemented a reinforcement (or boosting) logic on top of the n-tuple classifier that recognizes EMNIST digits. After about 100 iterations of that, the code went from ~80% accuracy to 95%!

- Alex; 20180429

     April 28th, 2018

Scientists Have Confirmed a New DNA Structure Inside Human Cells. Awesome stuff.

North Korea will close main nuclear test site in May, South says. Wow. The impossible is actually happening!

- Alex; 20180428

     April 26th, 2018

Filler...

- Alex; 20180426

     April 23rd, 2018

Why everyone is stressing about the 10-year Treasury yield. Uh, oh.

In other news, finally heard back from $CORP_NAME. The background check is mostly done, except for a few things that they're willing to do after I join. So they've asked me for the start date.

Coincidentally, today is exactly two months since my last day at FINRA :-)

As much as I like relaxing, I'll probably start next week.

- Alex; 20180423

     April 17th, 2018

So apparently my old ZenPad, that `broke' almost a year ago (the wifi wasn't coming up---no matter how many resets I've done, etc.; I thought it was a hardware issue---wifi chip burned out, or something) suddenly came back to live and started working again (wifi and everything).

In other news, discovered that my calendar was wrong. One of my classes actually starts 10 minutes earlier (6:05pm) than is marked in my calendar (6:15pm). So I've been showing up late most of the semester! This is pretty embarrassing :-/

UPDATE: So to add to my embarrassment, this time, I showed up on time... but to the wrong classroom. 232NE vs 234NE. They're nearly identical, and I really didn't pay attention which one I walked into. Strangely enough, some students actually showed up in the wrong classroom---so for about 20 or so minutes we were wondering what happened to the rest of the class :-/

- Alex; 20180417

     April 16th, 2018

Yey, kiddo had his first meal today: baby oatmeal!

- Alex; 20180416

     April 4th, 2018

Urgh. Apparently Yahoo! Finance API is gone. Didn't notice it until today :-/

- Alex; 20180404

     April 2nd, 2018

This doesn't happen every day: an actual snowy day in NYC... in April!

- Alex; 20180402

     March 28th, 2018

Visited two Toys R Us today.

In other news, accepted $CORP_NAME offer.

- Alex; 20180328

     March 27th, 2018

Ok, I think I might need to create some exams soon :-/

Heard back from $SOCIAL_MEDIA_CORP. They have made a ``difficult decision not to move forward at this time.'' So... amm... The Paradox of Choice: I'm pretty relieved. I've given them a try, a very fair chance to hire me, and they chose not to, so... yey!

Guess it would've been weird of them to hire someone whose never had (and still doesn't have) a $SOCIEAL_MEDIA_CORP account :-)

- Alex; 20180327

     March 26th, 2018

Having HSBC Quant dinner event. Rhydian Cox, HSBC Chief Risk Officer did audiance polling on stuff like when was HSBC founded, how many countries they operate in, which country had the first HSBC ATM machine, etc., and all sorts of similar trivia questions. Winners got HSBC branded insulated bottles. I didn't win anything. The dinner was grass with mayonnaise. And beer. Lots of beer. (and wine). All in all, a pretty useless event.

In other news, $CORP_NAME came back with an offer.

- Alex; 20180326

     March 25th, 2018

Changed oil in my 4runner.

- Alex; 20180325

     March 24th, 2018

Kiddo said "ma-ma". For first time. He was just moving lips up and down, and saying "aaa..." sound, and it came out as a pretty clear "ma-ma" sound.

- Alex; 20180324

     March 23rd, 2018

Got kiddo a stroller. Toys R us is going out of business, and had a 20% off sale on a stroller we wanted, so we just bought it... without doing any research. It looked good, and sturdy, etc. But... it's VERY heavy. I should have thought of that as I lifted the box in the store. Anyways, Suneli can't lift it---it's very easy to push around, big sturdy wheels, but getting it in and out of the car is gonna be a major pain. We'll likely need a lighter stroller just for car-trips.

Had an in-person $SOCIAL_MEDIA_CORP interview. They did career discussion, two design hours, two coding hours, and one lunch hour.

Coding 1, they asked to implement string.h function:
char *strstr(const char *haystack, const char *needle)
which surprisingly to me, was a challenge. It *looks* easy, but actually doing it, if you haven't done it in forever (like in 20 years), isn't trivial. I think I got code that worked---very basic loop through haystack, and then another loop that goes through needle. Very inefficient, but eh.

Second coding question was: this is all 2D: there's a ship in a tunnel with circular obstacles. Height of tunnel is H (so from 0 to H in y axis), and each obstacle is some object that has {x,y,rad}. You're given input of H and a list of obstacles, and your function has to return true or false whether the ship can make it through the tunnel.

If there are no obstacles, the ship makes it through. If there's 1 obstacle that blocks the whole tunnel, obviously the ship doesn't make it though. If there are two obsacles placed such that there's a tiny hole in-between, then the ship makes it though. But if those two obstacles are really next to each other, they could bock the tunnel. You could have dozens of obstacles forming a barrier for the ship.

My first reaction to this question was WTF!? This is a 45 minute programming assignment???

My second reaction, there's gotta be a trick to it. This should be easy to program. Obviously you can't compare ship to each obstacles, since obstacles can combine to block passage (while individual obstacles may not block tunnel).

Ok, so how to you combine obstacles? If they're touching of course. So there should be some way to glue touching obstacles into.... COMPONENTS. Connected components! Graph theory pays off!

So the solution I came up with is to use depth-first-search on obstacles, to build connected components (using distance to determine if they're conected---distance is less than or equal to sum of radisuses). Once you have components, for the entire component, if the maximum y plus radius is above the tunnel (greater than H), AND minimum y minus radius is below the tunnel (less than 0), and that component blocks the tunnel. Finished coding just in time.

I'm very proud of figuring out this one on the fly. It's a damn hard question.

Then there were two architecture questions. One related to notifications (e.g. push vs pull notification, and how they'd scale... e.g. pull doesn't need the server to maintain state, push requires server to keep list of clients, and can't be scaled as easily), etc.

The other architecture question had to do with designing priority metric for a search---you type in something into a search box, and a list of a dozen or so things show up that you might be interested in. How do we get that dozen that you might be interested in. After a bit of discussion, I proposed an architecture where we pull top N (perhaps 10000) records that start with the search prefix string, and then rank those by the user's profile preferences.

So there would be two rankings, one is some global ranking (applies to everyone), and within the top N of that global ranking, what you'd personally see would be determined by your personal rankings. Then questions went into the direction of how to determine global rankings (by how many people visit/watch/like, etc.) and personal rankings (how long you've stayed at a site, what kind of content you generally consume, etc., like a personalized feature vector, etc.)

All in all, the architecture questions were very hand-wavy and fuzzy. But I guess that was their purpose.

Lunch was great.

The final coding question is the one I got stumped on. Given a string of digits, such as "23562" insert any number of "+" or "-" to have the outcome be some N, e.g. "23+5-6+2" = 24. Write a function that outputs all the possible strings that sum to N.

This puzzle seems easy---and I thought of some sort of recursion---at every digit, you can either insert nothing, insert a "+" or insert a "-", and you need to explore all the subtrees of those choices. But no matter what I tried to setup, just couldn't get the right iteration going... and 45 minutes ran out :-/

UPDATE, sat down on the weekend and it wasn't really as complicated as it seemed. Non-recursive 17 lines of Perl code. In about 20 minutes (yes, I've been thinking about it for the last few days). So yeah, it was possible to do it during interview:

$ perl fbdigit.pl 123456 100
$ perl fbdigit.pl 1234567 100
+1+2+34+56+7 = 100
+1+23+4+5+67 = 100
$ perl fbdigit.pl 12345678 100
+1-2-3+45+67-8 = 100
+1-2+34-5-6+78 = 100
+1+23-4+5+67+8 = 100
+12+3-4+5+6+78 = 100
+12+34-5+67-8 = 100
$ perl fbdigit.pl 123456789 100
-1+2-3+4+5+6+78+9 = 100
+1+2+3-4+5+6+78+9 = 100
+1+2+34-5+67-8+9 = 100
+1+23-4+5+6+78-9 = 100
+1+23-4+56+7+8+9 = 100
+12-3-4+5-6+7+89 = 100
+12+3-4+5+67+8+9 = 100
+12+3+4+5-6-7+89 = 100
+123-4-5-6-7+8-9 = 100
+123+4-5+67-89 = 100
+123-45-67+89 = 100
+123+45-67+8-9 = 100

- Alex; 20180323

     March 22nd, 2018

Apparently I'm still in the running for $CORP_NAME. It's just taking them a while to come up with an offer. Should hear back from them shotly.

- Alex; 20180322

     March 21st, 2018

Ok, so this blizzard started out slow, but then over the entire day, piled up quite a bit of snow. Too bad it will all melt within a day :-/

In other news, missed an email from $CORP_NAME HR, who wanted `to catch up'. Hmm. Will chat with them tomorrow morning.

- Alex; 20180321

     March 20th, 2018

Urgh, another blizzard.

How a Self-Driving Uber Killed a Pedestrian in Arizona, and Arizona police release video of fatal collision with Uber self-driving SUV. My outsider guestimate, it's a similar case to when Tesla hit a firetruck: it just wasn't expecting to see anyone walking across the road, so it ignored them---there are lots of stationary things on or near the road that the self-driving car must ignore (traffic signs, images on the road, garbage on the road, etc.). This wasn't at a cross walk, and seemed to be right in the middle of the road; not a place you generally see pedestrians---and frankly, a human driver would've hit that pedestrian too.

In other news, got an NDA email from $SOCIAL_MEDIA_CORP. Signed it. Essentially I can't use any proprietary stuff I learn from them during the interview, but whatever I reveal during the interview, they're free to take it and use it however they wish.

Had another long tech interview at $FIN_CORP. I'm almost tempted to join---they sure got some sharp folks there. The work they do is also kind of in-line with what I'd want to do.

- Alex; 20180320

     March 19th, 2018

Finally got my car `fixed'. Replaced passenger-side air-bag inflator... so now feel safer :-)

$SOCIAL_MEDIA_CORP called and scheduled an in-person interview this Friday. Their email contains a lot of preperation material. But... the recruiter says: "they can ask you anything", and then says "ok, it's best if you prepare"... for what can you prepare... if they can ask you about anything?

It's times like this, you either know stuff or you don't.

$SOCIAL_MEDIA_CORP has a huge graph of relationships. As well as directed graph of following relationships. So... my guess questions could be related to: friend recommendations (in real life, if you're friends with two people, perhaps they'll also wanna be friends with each other?). But I'm guessing they've solved this problem already. How does one pick those out from a graph? Other questions could be related to similarity scores, e.g. if folks are both following a particular celebrity, then they're in some sense equivalent---have similar interests. If one of them follows a trendy new singer, perhaps the other one will also want to follow that trendy new singer?

Articulation points and bridges? Those are individuals and relationships that could be key to connectedness of a graph. I'm just thinking what graph theory stuff could fit into their business model.

In still other news, $FIN_CORP setup a 2nd in-person interview for tomorrow---to go over the homework solution I'm guessing.

- Alex; 20180319

     March 18th, 2018

Work work work on the PhD day...

In other news, Suneli started driving school. Took the "5-hour" pre-driving class (which was closer to 2-hours than 5), and drove a car for... I'm guessing 30-40 minutes :-)

In other news, finished $FIN_CORP homework. Spark/Scala. Not too bad. Hopefully most of it works. The basic idea: you have a quote feed (in pipe delimited FIX-like format). Some quotes are from venues, and others are consolidated quotes. The venues could publish either bid, or ask side of the quote (separately). The consolidated quote is indicated by not having a venue code.

Task 1: for all venue quotes, create a list of filled-in quotes, (fill in the missing side). That's easily done by doing a "last" windowing function, with "true" as the 2nd parameter (that's the ignore nulls flag).

Task 2: a bit more complicated: for each consolidated quote, indicate the count of venues that are quoting that price. (e.g. for each bid, and ask, add a count of venues).

There are several ways of doing this one. I decided to save the last bid/ask price for each venue (in a map), and whenever I saw a consolidated quote, just go through all saved venues and count those values where consolidated price matches the venue price.

So the usual repartition then sortWithinPartitions, then mapPartitions, and use the Map within the iterator... output is all quotes, except consolidated quotes got two extra counters, one for bid and one for ask.

Filter to keep only consolidated quotes, and... done. Write out the output.

- Alex; 20180318

     March 16th, 2018

Had an in-person interivew with $FIN_CORP . Very small firm. 6-people total, I think. They manage assets (hedge fund, of sorts). They used to do HFT a while back, but now do day-to-day or week-to-week positions. Most of the technical questions weren't very interesting (e.g. databases, etc.)

Interesting questions came from their quant guy. He asked me differences between sample variance and population variance. How market cap of a company impacts variance (apparently one can use market cap as a proxy for variance).

Here's the question: given a table, with x-axis being stocks, and y-axis dates (or timestamps), and values in the table being closing prices, for example. If you calculate covariance matrix, you end up with a variance of each stock to each other stock. Eigenvectors of that matrix correspond to portfolios that are correlated.

Inverse of covariance matrix gets you the precision matrix, which you can use to get portfolios. In theory. However, if you start with historical data, you end up with an estimate of the covariance matrix.

Now, the question, how does using a sample (not population) covariance matrix screw things up?

An inverse will essentally take an inverse of each eigenvalue... so the things with the lowest eigenvalues will get the biggest precision. So stuff that varies the most and isn't correlated with anything---often tiny cap stocks---will dominate the portfolios formed from sample covariance matrix. Stuff I didn't know before the interview :-)

As for $FIN_CORP , they gave me a Spark homework to do over the weekend. Reading stock quotes from various places and doing stuff with them. Easy stuff.

- Alex; 20180316

     March 15th, 2018

So... will the Fed raise interest rates on March 20th?

In other news, had a coding (coderpad) interview with $SOCIAL_MEDIA_CORP. The question they asked: if you're given a function such as int read4k(char* buf), that reads 4k of data, and returns number of bytes read, implement another function, int read(char* buf, int siz) that will have a more flexible interface---allow for reading of any siz (including 1 byte, or much more than 4k of data). It's been a really long while since I've done buffering at this kind of level, so it took me almost 30 minutes of tinkering before I managed to setup an iteration that worked.

- Alex; 20180315

     March 14th, 2018

Happy PI day!

Happy landing anniversary!

And in other news, Stephen Hawking died. His book, A Brief History of Time was literally the first book I've ever borrowed from a library (yes, eventually I bought a copy of my own). That book inspired me to read more and more on the subject.

His primary idea, that black holes evaporate, is awesome. It's very weird how it works if you think about it... a pair of virtual particles forms just at the endge of the event horizon. One of them falls in, and somehow that causes the black hole to get smaller! (the system of the particle outside the black hole has more energy than the system with the particle already in the black hole---and that energy difference is carried off by the other particle of the virtual pair). Pretty awesome stuff.

- Alex; 20180314

     March 13th, 2018

So my car (Toyota 4Runner) was recalled due to faulty passenger-side air-bag inflator. Scheduled an appointment at and went to Queensborough Toyota to have it serviced---and after walking around their showroom for about an hour, waiting for my car to get done, they come back and say they don't have the part and will need to order it :-/

So will need to come back. Urgh. Why couldn't they have ordered the part before the appointment? They knew WHY I was coming there, they knew exactly the car and year, etc., it's not like they couldn't have known they don't have the part :-/

- Alex; 20180313


Or, you can directly go to a desired entry.
   




NOTICE: We DO NOT collect ANY personal information on this site.
© 1996-2016 by End of the World Production, LLC.