when there’s (implicit) measure+when there is none

Needs a Measure – r or mu. Whenever we see “drift”, it means expected growth or the Mean of some distribution (of a N@T). There’s a probability measure in the context. This could be a physical measure or a T-fwd measure or a stock-numeraire or the “risk-neutral-measure” i.e. MoneyMarketAcct as the numeraire

Needs a Measure – dW. Brownian motion is always a probabilistic notion, under some measure

Needs a Measure – E[…] is expectation of something. There’s a measure in the context.

Needs a Measure – Pr[..]

Needs a Measure – martingale

Regardless of measure – time-zero fair price of any contract. The same price should result from derivation under any measure.

Regardless of measure – arbitrage is arbitrage under any measure

option pricing – 5 essential rules n their assumptions

PCP — arb + extremely tight bid/ask spread + European vanilla option only. GBM Not assumed. Any numeraire fine.

Same drift as the numeraire — tradeable + arb + numeraire must be bond or a fixed-interest bank account.

no-drift — tradeable + arb + using the numeraire

Ito — BM or GBM in the dW term. tradable not assumed. Arb allowed.

BS — tradable + arb + GBM + constant vol

quasi constant parameters in BS

dS/S = a dt + b dW [1]

[[Hull]] says this is the most widely used model of stock price behavior. I guess this is the basic GBM dynamic. Many “treasures” hidden in this simple equation. Here are some of them.

I now realize a and b (usually denoted σ) are “quasi-constant parameters”. The initial model basically assumes constant [2] a and b. In a small adaptation, a and b are modeled as time-varying parameters. In a sense, ‘a’ can be seen as a Process too, as it changes over time unpredictably. However, few researchers regard a as a Process. I feel a is a long-term/steady-state drift. In contrast, many treat b as a Process — the so-called stochastic vol.

Nevertheless in equation [1], a and b are assumed to be fairly slow-changing, more stable than S. These 2 parameters are still, strictly speaking, random and unpredictable. On a trading desk, the value of b is typically calibrated at least once a day (OCBC), and up to 3 times an hour (Lehman). How about on a volatile day? Do we calibrate b more frequently? I doubt it. Instead, implied vol would be high, and market maker may jack up the bid/ask spread even wider.

As an analogy, the number of bubbles in a large boiling kettle is random and fast-changing (changing by the second). It is affected by temperature and pressure. These parameters change too, but much slower than the “main variable”. For a short period, we can safely assume these parameters constant.

Q: where is √ t
A: I feel equation [1] doesn’t have it. In this differential equation about the instantaneous change in S, dt is assumed infinitesimal. However, for a given “distant future” from now, t is given and not infinitesimal. Then the lognormal distribution has a dispersion proportional to √ t

[2] The adjective “constant” is defined along time axis. Remember we are talking about Processes where the Future is unknown and uncertain.

change measure but using cash numeraire #drift

Background — “Drift” sounds simple and innocent, but no no no.
* it requires a probability measure
* it requires a numeraire
* it implies there’s one or (usually) more random process with some characteristics.

It’s important to estimate the drift. Seems essential to derivative pricing.
—————————————————————————
BA = a bank account paying a constant interest rate, compounded daily. No uncertainty no pr-distro about any future value on any future date. $1 today (time-0) becomes exp(rT) at time T with pr=1 , under any probability measure.

MMA = money market account. More realistic than the BA. Today (time-0), we only know tomorrow’s value, not further.
Z = the zero coupon bond. Today (time-0) we already know the future value at time-T is $1 with Pr=1 under any probability measure. Of course, we also know the value today as this bond is traded. Any other asset has such deterministic future value? BA yes but it’s unrealistic.
S = IBM stock
Now look at some tradable asset X. It could be a stock S or an option C or a futures contract … We must must, must assume X is tradable without arbitrage.
—- Under BA measure and cash as numeraire.
   X0/B0 = E (X_T/B_T) = E (X_T)/B_T   =>
   E (X_T)/X0 = B_T/B0
Interpretation – X_T is random and non-deterministic, but its expected value (BA measure) follows the _same_ drift as BA itself.
—- Under BA measure and using BA as numeraire or “currency”,
   X0/B0 = E (X_T/B_T)
Interpretation – evaluated with BA as currency, the value of X will stay constant with 0 drift.
—- Under T-measure and cash numeraire
   X0/Z0 = E (X_T/Z_T) = E (X_T)/$1   =>
   E (X_T)/X0 = 1/Z0
Interpretation — X_T is random and non-deterministic, but its expected value (Z measure) follows the _same_ drift as Z itself.
—- Under T-measure and using Z as numeraire or “currency”,
   X0/Z0 = E (X_T/Z_T)
Interpretation – evaluated with the bond as currency, the value of X will stay constant with 0 drift.
—- Under IBM-measure and cash numeraire
   X0/S0 = E (X_T/S_T)
Interpretation – can I say X follows the same drift as IBM? No. The equation below doesn’t hold because S_T can’t come out of E()!
     !wrong —>       E (X_T)/X0 = S_T/S0    ….. wrong!
—- Under IBM-measure and IBM numeraire… same equation as above.
Interpretation – evaluated with IBM stock as currency, the value of X will stay constant with 0 drift.

Now what if X is non-tradable i.e. not the price process of a tradable asset? Consider random variable X = 1/S. X won’t have the drift properties above. However, a contract paying X_T is tradeable! So this contract’s price does follow the drift properties above. See http://bigblog.tanbin.com/2013/12/tradeablenon-tradeable-underlier-in.html

numeraire paradox

Consider a one-period market with exactly 2 possible time-T outcomes w1 and w2.

Among the tradable assets is G. At termination, G_T(w1) = $6 or G_T(w2) = $12. Under G-measure, we are given Pr(w1) = Pr(w2) = 50%. It seems at time-0 (right now) G_0 should be $9, but it turns out to be $7! Key – this Pr is inferred from (and must be consistent with) the current market price of another asset [1]. Without another asset, we can’t work out the G-distro. In fact I believe every asset’s current price must be consistent with this G-measure Pr … or arbitrage!

Since every asset’s current price should be consistent with the G-Pr, I feel the most useful asset is the bond. Bond current price works out to Z_0 = $0.875. This implies a predicable drift rate.

I would say under bond numeraire, all assets (G, X, Z etc) have the same drift rate as the bond numeraire. For example, under the Z-numeraire, G has the same drift as Z.

Q: under Z-measure, what’s G’s drift?
A: $7 -> $8

It’s also useful to work out under Z-measure the Pr(w1) = 66.66% and Pr(w2) = 33.33%. This is using the G_0, G_T numbers.

Now can there be a 0-interest bank account B? In other words, could B_T = B_0 = $1? No, since such prices imply a G-measure Pr(w1) like 5/7 (Verified!) So this bank account’s current price is inconsistent with whatever asset used in [1] above.

The most common numeraires (bank accounts and discount bonds) have just one “outcome”. (In a more advanced context, bank account outcome is uncertain, due to stoch interest rates.) This stylized example is different. Given a numeraire with multiple outcomes, it’s useful to infer the bond numeraire. It’s generally easier to work with one-outcome numeraires. I feel it’s even better if we know the exact terimnal price and the current price of this numeraire — I guess only the discount bond meet this requirement.

I like this stylized 1-period, 2-outcome world.
Q1: Given Z_T, Z_0, G_0, G_T [2], can i work out the G-Pr (i.e. distro under G-numeraire)? can i swap the roles and work out the Z-Pr ?
A: I think we can work out both distros and they aren’t identical !

Q2: Given G_0 and the G_T possible values[2] without Z prices, can we work out the G-Pr (i.e. distro under G-numeraire)?
A: no we don’t have a numeraire. In a high vs a low interest-rate world, the Pr implied by G_T would be different

[2] these are like pre-set enum values. We only know these values in this unrealistic world.

"uninitialized" is either a pointer or a primitive type

See also http://bigblog.tanbin.com/2013/07/c-uninitialized-static-objects-auto.html

1) uninitialized variable of primitive types — contains rubbish
2) uninitialized pointer — very dangerous.

We are treating rubbish as an address! This address may happen to be Inside or Outside this process’s address space.

Read/write on this dereferenced pointer can lead to crashes. See P161 [[understanding and using C pointers]].

There are third-party tools to help identify uninitialized pointers. I think it’s by source code analysis. If function3 receives an uninitialized pointer it would look completely normal to the compiler or runtime.

3) uninitialized class instance? Possible. Every class instance in c++ will have its memory layout well defined, though a field therein may fall into category 1) or 2) above.

4) uninitialized array of pointers could hold wild pointers

"volatile" in c++ #hardware eg

(See other posts on volatile.) I now get more and more questions on this keyword.

Now i think a volatile variable can be updated by another thread, another process, or by hardware (via interrupts). P206 [[from c to c++]] has a “hardware” example.

P178 [[understanding and using c pointers]] shows how to read a hardware port, declared as a const pointer to a volatile integer object —

    unsigned int volatile * const port = ….

Unlike in java, Volatile can also be used on regular variables, methods, fields. Similar restriction as “const”.

IV spr/hib, SQL, …

———- Forwarded message ———-

From: Hai Yi
Date: 23 January 2014 11:24
Subject: Citi interview (01/22/14)

this is a tough one, a real torture

input an array of strings, how to eliminate the dups and output a new array. Don’t use iteration of each element.
That is to take advantage of Set#addAll and Set#toArray
Write Factorial in two ways
recursive and non-recursive
How to customize serialization, what methods to use?
Normally the serialization in Java works in this way:
An object to be serialized, say A, needs to implement Serializable interface;
From program, use ObjectInputStream/ObjectOutStream to read in / write A.
To customize the serialization, you have to implement readObject/writeObject inside A, and both methods should be “private”.
A second way to customize serialization is to implement Externlizable – be noted this one is NOT a mark interface and it has two methods readExternal / writeExternal
the dynamic proxy in Java, whats its name?
Proxy
JNI is loaded into which area of the heap? Say for example, an oracle driver
How to record the hit counter from an application server in a multi-threading environment.
AtomicInteger
optimistic lock and pessimistic lock, what exactly the SQL in Oracle to implement them?
for optimistic lock, use an additional column in Table, with type being “Timestamp” or “version” and check it before updating.
For pessimistic lock, add “For Update” clause in the SQL thus effectively lock the access to the table.
what’s the default autowiring in Spring?
Autowired by type
whats the JVM argument is used for GC?
What the tools for memory dump?
1 mil transaction per sec down to 1 transaction in an application server, what’s the primary suspect?
How to prevent the field from being persisted.
transient keyword
How to implement lazy loading in Hibernate?
lazy load in Hibernate is one of Hibernate’s fetching strategies, its purpose is to load the related children of an entity only when the user needs them.
if using XML config, in hbm.xml, use attribute fetch = “select”
If using annotation, do these:
    @OneToMany(fetch = FetchType.LAZY, mappedBy = "stock")
     @Fetch(FetchMode.SELECT)
How to use Query in Hibernate? And Criteria ?
What are the patterns implemented in Hibernate?
ApplicationContext, what is more than BeanFactory?
maven, phase:goal, explain.
Macro processor in Linux?
Now I know you are just playing me…