<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title><![CDATA[A rude assembly]]></title>
  <link href="http://www.seamusbradley.net/blog/atom.xml" rel="self"/>
  <link href="http://www.seamusbradley.net/blog/"/>
  <updated>2013-03-06T21:21:53+01:00</updated>
  <id>http://www.seamusbradley.net/blog/</id>
  <author>
    <name><![CDATA[Seamus Bradley]]></name>
    
  </author>
  <generator uri="http://octopress.org/">Octopress</generator>

  
  <entry>
    <title type="html"><![CDATA[White's coin puzzle: a response]]></title>
    <link href="http://www.seamusbradley.net/blog/blog/2013/03/06/whites-coin-puzzle-a-response/"/>
    <updated>2013-03-06T21:15:00+01:00</updated>
    <id>http://www.seamusbradley.net/blog/blog/2013/03/06/whites-coin-puzzle-a-response</id>
    <content type="html"><![CDATA[<p>So I carved off a short section of my thesis and tidied it up into a little paper
on Roger White’s coin puzzle for imprecise credences.
If you like that sort of thing,
you can find the paper
<a href="http://www.seamusbradley.net/Papers/coins-redux.pdf">over here</a> (PDF).
Comments welcome!
By email, or by twitter if you’re hip and modern.
And your comment is less than 140 characters.</p>

<p>I’m not going to summarise the paper here because it’s only 6 pages long,
and you might as well just read it!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Static and dynamic norms versus preferring and not dispreferring]]></title>
    <link href="http://www.seamusbradley.net/blog/blog/2013/03/05/static-and-dynamic-norms-versus-preferring-and-not-dispreferring/"/>
    <updated>2013-03-05T16:02:00+01:00</updated>
    <id>http://www.seamusbradley.net/blog/blog/2013/03/05/static-and-dynamic-norms-versus-preferring-and-not-dispreferring</id>
    <content type="html"><![CDATA[<p>I’ve been thinking about rationality requirements for sequences of choices.
It seems there’s a sense in which some synchronic (static) norms
are justified by related diachronic (dynamic) norms.
I recently hit an interesting snag in this picture.</p>

<!-- more -->

<p>So let’s think about the package principle.
This is an important part of the Dutch book theorem.
The package principle says that (in effect) if you prefer
bet A to bet B and you prefer bet C to bet D,
then you should prefer the set of A and C to the set of B and D.
Dutch book results work by making nonprobabilistic agents take sets of bets
guaranteed to lose them money.
So agents need to have consistent attitudes to sets of bets to make it work.
As a static principle, it is a little artificial.
This is a point that <a href="http://philpapers.org/rec/SCHDBA">Schick</a> makes.
The principle seems to be motivated by a <em>dynamic</em> principle that says that
if you’re offered the bets in sequence,
your preferences among bets shouldn’t be sensitive to what bets you’ve already taken.
This is just avoiding the fallacy of the sunk cost, I guess.</p>

<p>The motivation goes like this:
say you preferred A to B and C to D as before.
Now if I offered you the choice between A and B,
you’d choose A.
It seems that if I now offered you the choice between C or D,
you should still go for C.
That is,
having chosen A shouldn’t affect your preferences among bets.</p>

<p>I’ll come back to the package principle in a moment,
but let’s consider another example of a static principle motivated by dynamic concerns.
Think about arguments against having cyclic preferences.
If you had cyclic preferences, that is $ a \succ b \succ c \succ a$,
then you could be money-pumped.
Let’s say the letters stand for Apple, Banana and Carrot.
If you had a carrot, I could offer to exchange your carrot for a banana.
Since you strictly prefer the banana, you would be willing to pay me for the privilege of trading up.
Now I offer you an apple for your banana, likewise, you’d pay to trade up.
But you also prefer carrots to apples, so again you’d pay me to trade up to the carrot.
Now you are back where you started except that you paid me for each exchange.
You have been money-pumped.
Not that the money pump involves offering trades in sequence.
Thus acyclicity – a static condition on preference –
is motivated by appeal to sequences of choices.</p>

<p>OK, back to the package principle.
Here’s a very similar argument to the one dynamic one above,
but the static condition it seems to motivate is unreasonable.
Say you don’t disprefer A to B and you don’t disprefer C to D.
We’re imagining agents who can have incomplete preferences, here.
Say you had imprecise beliefs and the expectation intervals for A and B overlapped.
Now, if you were offered the choice between A and B,
on a reasonable interpretation of what’s permissible given incomplete preference
we could say that it’s permissible for you to choose A.
Now if you were then offered the choice between C and D,
it should still be permissible for you to choose C.
The static principle that this line of reasoning seems to motivate, however,
is not a good one.
Consider, for example, the “great set of bets” that 
<a href="http://www.princeton.edu/~adame/papers/sharp/elga-subjective-probabilities-should-be-sharp.pdf">Adam Elga</a>
offers.
He first offers you the lottery “-10 if H, 15 if not-H” then he offers you the lottery “15 if H, -10 if not-H”.
If these are A and C respectively (where B and D are both the “status quo”),
then it should be clear that you should never choose to refuse both bets.
Now if you have imprecise credence in the proposition H, 
it may be that you have no preferences between A and B nor between C and D.
Thus it is permissible that you accept B, and also that you accept D.
But in the static choice between AC, A, C and the status quo, you would never
opt for the status quo.
So what has gone wrong?</p>

<p>To recap, it looks like the method for justifying static principles of choice through
dynamic considerations has led us to a static principle we would want to reject.
Does this cast doubt on the method as used in the previous cases?
Or is there something weird about the relation of “not dispreferring” and the
concept of permissibility derived from it that makes the method inapplicable?
I don’t really know what to say about this case yet.
Katie Steele and I have been working on a <a href="http://www.seamusbradley.net/Papers/elga.pdf">paper</a>
on this topic.</p>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Bertrand Russell quotes]]></title>
    <link href="http://www.seamusbradley.net/blog/blog/2013/03/02/bertrand-russell-quotes/"/>
    <updated>2013-03-02T11:19:00+01:00</updated>
    <id>http://www.seamusbradley.net/blog/blog/2013/03/02/bertrand-russell-quotes</id>
    <content type="html"><![CDATA[<p>Flicking through the “my clippings” thing on my kindle for my 
<a href="http://www.seamusbradley.net/blog/blog/2013/02/27/raymond-chandler-quotes/">Chandler quotes</a>
post, I realised that I have many gems from Russell’s
<em>History of Western Philosophy</em> also saved on there.
Again, this reflects more on what I find amusing than on what
Russell wrote or thought.
While we’re on the subject of Russell, Jorge Luis Borges, in an article about Zeno’s paradox
describes Russell as “inhumanly lucid”.</p>

<!-- more -->

<blockquote><p>Uncertainty, in the presence of vivid hopes and fears, is painful, but must be endured if we wish to  live without the support of comforting fairy tales.</p></blockquote>

<blockquote><p>It is clear that each party to this dispute &#8211; as to all that persist through long periods of time &#8211; is partly right and partly wrong.</p></blockquote>

<blockquote><p>The civilised man is distinguished from the savage mainly by prudence, or, to use a slightly wider term, forethought. He is willing to endure present pains for the sake of future pleasures, even if the future pleasures are rather distant.</p></blockquote>

<blockquote><p>He founded a religion, of which the main tenets were the transmigration of the soul and the sinfulness of eating beans. His religion was embodied in a religious order, which, here and there, acquired control of the State and established a rule of the saints. But the unregenerate hankered after beans, and sooner or later rebelled.</p></blockquote>

<p>(I think he is talking about Pythagoras here, and in the next quote.)</p>

<blockquote><p>To those who have reluctantly learnt a little mathematics in school this may seem strange; but to those who have experienced the intoxicating delight of sudden understanding that mathematics gives, from time to time, to those who love it, the Pythagorean view will seem completely natural even if untrue. It might seem that the empirical philosopher is the slave of his material, but that the pure mathematician, like the musician, is free creator of his world of ordered beauty.</p></blockquote>

<blockquote><p>To learn to conceive the universe according to each of these systems is an imaginative delight and an antidote to dogmatism. Moreover, even if no one of the hypotheses can be demonstrated, there is genuine knowledge in the discovery of what is involved in making each of them consistent with itself and with known facts.</p></blockquote>

<blockquote><p>His words, like those of all the philosophers before Plato, are known only through quotations, largely made by Plato and Aristotle for the sake of refutation. When one thinks what would become of any modern philosopher if he were only known through the polemics of his rivals, one can see how admirable the pre-Socratics must have been, since even through the mist of malice spread by their enemies they still appear great.</p></blockquote>

<p>This next one is Russell quoting Protagoras:</p>
<blockquote><p>&#8220;With regard to the gods, I cannot feel sure either that they are or that they are not, nor what they are like in figure; for there are many things that hinder sure knowledge, the obscurity of the subject and the shortness of human life&#8221;</p></blockquote>

<blockquote><p>Any logically coherent body of doctrine is sure to be in part painful and contrary to prejudices.</p></blockquote>

<blockquote><p>What is important to the historian of the world is not the petty wars between Greek cities, or the sordid squabbles for the part ascendancy, but the memories retained by mankind when the brief episode was ended &#8211; like the recollection of a brilliant sunrise in the Alps, while the mountaineer struggles through and arduous day of wind and snow.</p></blockquote>

<blockquote><p>But whatever Socrates may say, it remains the case, as any one can see, that people who stick to philosophy become strange monsters, not to say utter rogues; even the best of them are made useless by philosophy.</p></blockquote>

<blockquote><p>This is, I think, what Aristotle means. His doctrine on this point, as on many others, is a common-sense prejudice pedantically expressed.</p></blockquote>

<blockquote><p>Scepticism was a lazy man&#8217;s consolation, since it showed the ignorant to be as wise as the reputed men of learning. To the men who, by temperament, required a gospel, it might seem unsatisfying, but like every doctrine of the Hellenistic perios it reccommended itself as an antidote to worry. Why trouble about the future? It is wholly uncertain. You may as well enjoy the present; &#8220;what&#8217;s to come is still unsure&#8221;. For these reasons, Scepticism enjoyed a considerable success.</p></blockquote>

<p>This is Russell quoting a sceptic:</p>
<blockquote><p>&#8220;We sceptics follow in practice the way of the world, but without holding any opinion about it. We speak of the Gods as existing and offer worship to the Gods and say that they exercise providence, but in saying this we express no belief, and avoid the rashness of dogmatizers.&#8221;</p></blockquote>

<blockquote><p>Against brother-sister incest there is a very curious argument: that if the love of husband and wife were combined with that of brother and sister, mutual attractions would be so strong as to cause unduly frequent intercourse.</p></blockquote>

<p>Here’s Russell on Rousseau:</p>
<blockquote><p>Science and virtue, he held, are incompatible, and all sciences have an ignoble origin. Astronomy comes from the superstition of astrology; eloquence from ambition; geometry from avarice; physics from vain curiosity; and even ethics has its source in human pride.</p></blockquote>

<p>Here’s Russell quoting Rousseau in a letter to Voltaire, whom he had fallen out with.</p>
<blockquote><p>If there is nothing in you that I can honour but your talents, that is no fault of mine.</p></blockquote>

<blockquote><p>&#8220;Ah Madame!&#8221; writes Rousseau to an aristocratic lady, &#8220;sometimes in the privacy of my study, with my hands pressed tight over my eyes or in the darkness of the night , I am of opinion that there is no God. But look yonder: the rising sun, as it scatters the mists that cover the earth, and lays bare the wondrous glimmering scene of nature, disperses at the same moment all cloud from my soul. I find my faith again and my God and my belief in Him. I admire and adore Him, and I prostrate myself in His presence.&#8221;</p></blockquote>

<blockquote><p>This illustrates an important truth, namely, that the worse your logic, the more interesting the consequences to which it gives rise.</p></blockquote>

<blockquote><p>Philosophers may differ as to the definition of &#8220;truth&#8221;, but at any rate it is something objective, something which, in some sense, everybody ought to accept. No man would engage in the pursuit of philosophy if he thought that all philosophy is merely an expression of irrational bias.</p></blockquote>

<blockquote><p>We may say, in a broad way, that Greek philosophy down to Aristotle expresses the mentality appropriate to the City State; that Stoicism is appropriate to a cosmopolitan despotism; the scholastic philosophy is an intellectual expression of the Church as an organization; that philosophy since Descartes, or at any rate since Locke, tends to embody the prejudices of the commercial middle class; and that Marxism and Fascism are philosophies appropriate to the modern industrial State.</p></blockquote>

<blockquote><p>For one reason or another, we all find it impossible to maintain an attitude of sceptical detachment on many issues as to which pure reason is silent. A &#8220;philosophy&#8221;, in a very usual sense of the word, is an organic whole of such extra-rational decisions.</p></blockquote>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Raymond Chandler quotes]]></title>
    <link href="http://www.seamusbradley.net/blog/blog/2013/02/27/raymond-chandler-quotes/"/>
    <updated>2013-02-27T22:14:00+01:00</updated>
    <id>http://www.seamusbradley.net/blog/blog/2013/02/27/raymond-chandler-quotes</id>
    <content type="html"><![CDATA[<p>I recently read some Raymond Chandler books on kindle.
<em>The Big Sleep</em>, <em>Farewell My Lovely</em> and <em>The Long Goodbye</em>, if you’re interested.
Here are some bits of those books I felt compelled to highlight as I was reading.
This probably tells you more about me than it does about Chandler.</p>

<!-- more -->

<blockquote><p>You have to hold your teeth clamped around Hollywood to keep from chewing on stray blondes</p></blockquote>

<blockquote><p>I don&#8217;t have anything really exciting to drink like nitro-glycerine or distilled tiger&#8217;s breath</p></blockquote>

<blockquote><p>I drove back to Hollywood feeling like a short length of chewed string</p></blockquote>

<p>These quotes don’t really do justice to the books.
I enjoyed them all:
Chandler’s writing is tight and the stories compelling.
When you first start reading them you have to get over the fact that they sound like
the dialogue that films like <em>The Naked Gun</em> and <em>Dead Men Don’t Wear Plaid</em>
are parodying (because that’s what they are parodying).
For example, <em>The Big Sleep</em> opens like this:</p>

<blockquote><p>It was about eleven o&#8217;clock in the morning, mid October, with the sun not shining and a look of hard wet rain in the clearness of the foothills. I was wearing my powder-blue suit, with dark blue shirt and display handkerchief, black brogues, black wool socks with dark blue clocks on them. I was neat, clean, shaved and sober, and I didn&#8217;t care who knew it. I was everything the well-dressed private detective ought to be. I was calling on four million dollars.</p></blockquote>

<p>Once you stop reading it in Leslie Nielsen’s voice,
once you get into it, they’re really good stories.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Disagreement and revising peerhood]]></title>
    <link href="http://www.seamusbradley.net/blog/blog/2013/02/27/disagreement-and-revising-peerhood/"/>
    <updated>2013-02-27T14:35:00+01:00</updated>
    <id>http://www.seamusbradley.net/blog/blog/2013/02/27/disagreement-and-revising-peerhood</id>
    <content type="html"><![CDATA[<p>Here’s a thing I noticed recently during an interesting reading group discussion here at MCMP.
Disagreement is intensional.
We can disagree about whether Superman is in the room,
even if we agree that Clark Kent is in the room.
I’m not sure whether this has been noticed, or whether it has any interesting consequences,
but it seemed an interesting fact.</p>

<!-- more -->

<p>Now, this is an interesting thing in and of itself,
but I actually want to use it to talk about a more general phenomenon.
I want to talk about when it’s legitimate to revise how competent you are
in the light of learning that you disagree with me.
Obviously, we don’t want to do this too often or I will
never respond to testimonial evidence.
This would be a bad thing.
Indeed, it is such a bad thing that 
<a href="http://fitelson.org/seminar/christensen.pdf">David Christensen</a>
feels moved to ruled out ever changing opinions about competence 
in the light of disagreement.
This he calls a principle of “Independence”</p>

<p>Back to our disagreement about Superman.
It seems that if we learn we disagree about whether Superman is in the room,
and you believe he is not in the room, then maybe you should revise your beliefs.
But if we disagree that Superman is in the room and I believe he is in the room,
(since I know Superman is Clark Kent and we both know Clark Kent is in the room)
then it seems that this is good evidence that you don’t know that Superman is Clark Kent,
not evidence that one of us has made some serious mistake with respect to recognising who is in the room.
So even if I take you to be my peer with respect to recognising people in a room,
we don’t have equal reason to change our beliefs.</p>

<p>Well, perhaps what’s going on is that we aren’t peers with respect to recognising
Superman, since I know an important fact about Superman that you don’t.
Even if I believed (before the disagreement) that you <em>did</em> know Superman is Clark Kent,
it seems that I should revise that belief, rather than revise the belief that Superman is in the room.
This of course violates the “Independence” principle which says that learning of a disagreement
shouldn’t lead you to revise your beliefs about peerhood.
That is, if I had a prior belief that you were my peer with respect to
Superman recognition, your failure to recognise Superman
is evidence you aren’t really my peer.
It might also be evidence that Superman really isn’t in the room,
or that Superman isn’t Clark Kent.
That is, there are many ways I could revise my beliefs in response to the disagreement,
but some revisions are easier than others.</p>

<p>Cases of disagreement can perhaps be viewed as cases of coming to have an inconsistent belief
set and then having to revise the set.
So you start out with the following beliefs:</p>

<ul>
  <li>I am good at having true beliefs about $X$.</li>
  <li>You are as good at having true beliefs about $X$.</li>
  <li>I do/don’t believe $X$.</li>
</ul>

<p>I then learn:</p>

<ul>
  <li>You don’t/do believe $X$.</li>
</ul>

<p>There seems to be some serious tension between these four beliefs.
Something has got to give.
The Independence assumption seems to make the first two of my beliefs unrevisable.
I could drop one or both of latter two beliefs.
There seems to be something <em>ad hoc</em> or arbitrary about dropping either one belief,
so I should drop both and suspend judgement as to whether $X$.
This is what the “Equal Weight View” amounts to in cases of categorical belief like this.</p>

<p>In the Superman/Clark Kent example, I find it more reasonable that the belief about your
competence or your reliability is the one that should be dropped.
Let’s take for granted that “Superman is Clark Kent” is unrevisable for now.
I am so sure of my belief that Superman is in the room that my belief
about your competence is less entrenched – more easily revisable –
than my belief about Superman being in the room.
Even if “Superman is Clark Kent” is not unrevisable,
it still seems like the least strongly held of my beliefs
is that you are competent at recognising Superman.
Or rather, what revision is easiest for me in this circumstance is to drop
that belief.</p>

<p>Here’s another example.
We are both trying to do the sum $38\times 42$.
I say it is 1596, you say it is 1594.
Under most circumstances I take you to be a peer about arithmetic.
But in this case, I spotted that $38\times 42 = (40-2)(40+2) = 1600 - 4$.
So the best explanation of the disagreement is that you did not spot this trick
and you have made a mistake.
Again, it seems like there’s something about this example that suggests
revising the peerhood assumption, rather than effecting an epistemic compromise.
Note I am not revising my belief that we are generally equally competent at arithmetic,
I am revising only the belief that in this case, there’s something (the trick) that
makes my belief in the answer less revisable.</p>

<p>I think the right way to approach this area is to think in terms
of an agent’s beliefs about her own competence and the competence of others.
What this actually amounts to, or what competence actually is, I don’t know yet.
Watch this space.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Evidence and logical omniscience]]></title>
    <link href="http://www.seamusbradley.net/blog/blog/2013/01/25/evidence-and-logical-omniscience/"/>
    <updated>2013-01-25T12:48:00+01:00</updated>
    <id>http://www.seamusbradley.net/blog/blog/2013/01/25/evidence-and-logical-omniscience</id>
    <content type="html"><![CDATA[<p>There seems to be a tension between some putative norms of epistemology.
On the one hand, you are required to believe things you have
evidence for.
On the other hand, you are normatively compelled to
believe all the logical truths.
But you have no evidence for most logical truths.
What to make of this puzzle?</p>

<!-- more -->

<p>Any sensible epistemology should have some norm
that says something like 
“You are justified in believing those sentences
you have evidence for”.
Or something like that.
Well, that’s actually probably the wrong way to put it.
You can have evidence for something that is undermined by
other stronger evidence.
So let’s put the norm like this:
“You are not justified in believing sentences
you have no evidence for”.
Now, for some suitably broad definition of evidence,
I think this is a reasonable norm on belief.
I can’t help quoting 
<a href="http://www.infidels.org/library/historical/w_k_clifford/ethics_of_belief.html">W.K. Clifford</a>
on this point:</p>

<blockquote><p>it is wrong always, everywhere and for anyone to believe anything on insufficient evidence</p></blockquote>

<p>And 
<a href="http://educ.jmu.edu/~omearawm/ph101willtobelieve.html">William James</a>
agrees up to a point:</p>

<blockquote><p>All this strikes one as healthy, even when expressed by Clifford with somewhat too much robustious pathos in the voice. Free-will and simple wishing do seem, in the matter of our credences, to be only fifth wheels to the coach.</p></blockquote>

<p>James actually ends up saying that it is permissible
to believe things consistent with your
evidence, which allows you to believe things
you don’t have evidence for.
But I’ve always found Clifford to
be more right on this than James.
Anyway, we’ll come back to this discussion in a second.</p>

<p>Here’s another putative rational requirement:
“You ought to believe all the logical truths”.
That is, it normally follows from the norms on rational belief
that you ought to be logically omniscient.
I’ve talked about this before.
(<a href="http://www.seamusbradley.net/blog/blog/2012/02/22/decision-theory-for-the-logically-ignorant/">Once</a>,
<a href="http://www.seamusbradley.net/blog/blog/2012/02/28/dutch-booking-the-logically-ignorant/">Twice</a>,
and <a href="http://www.seamusbradley.net/blog/blog/2012/03/05/who-cares-about-logical-ignorance/">Thrice</a>).
For the moment I’m going to stick to categorical yes/no belief,
but I think everything I say is also true of the graded case.
Obviously, this is way too strong an assumption
to be reasonable of actual agents:
it is a counsel of perfection.
But it is a counsel nonetheless:
what reason could you have for failing to believe
a logical truth except ignorance?</p>

<p>What counts as evidence for a logical truth?
Obviously, a proof of a logical truth should count as evidence for it.
Perhaps we have some sort of inductive evidence that counts in favour of
certain open conjectures like Goldbach’s conjecture or
the twin prime conjecture.
But the problem is, that even if we allow all this,
<em>you have no evidence for most logical truths</em>.
Most logical truths are longer than all the strings of formal symbols
we have ever written down.
And thus longer than any possible proof of them that we have considered.
This is for exactly the same reason that most finite numbers are bigger than
all the numbers we have ever dealt with.
It seems crazy that I should be rationally required to believe an
enormous class of sentences for which I have no evidence.
It seems odd that an agent could be rationally required to believe
a huge class of sentences that she <em>couldn’t possibly</em> be justified in believing.</p>

<p>I take this as a reason to doubt that logical omniscience can really be a 
norm of rational belief.
We need something weaker.
We need to capture the idea that only ignorance could be a reason
for failing to believe a logical truth.
But we also need to allow agents to be ignorant in that way.</p>

<p>In fact, I’m not sure we really need an extra norm.
What we need is a notion of evidence that allows that 
evidence for $T$ is also evidence for $T \vee X$,
but is not evidence for some extremely long complex formula
that happens to be logically equivalent to $T$.
Then the evidential norm above is enough to guarantee that you
are required to believe the logical truths it is reasonable
to expect you to be able to believe.
The real change is in doing epistemology in a framework that 
even <em>allows</em> such failure of logical omniscience.
See above posts for why this is non-trivial.</p>

<p>I think the basic problem here is that 
<em>evidence and justification are intensional</em>.
You see Clark Kent walk into the office.
You are justified in believe Clark Kent is in the office,
but not that Superman is in the office.
Same thing is going on in the evidence for logical truths case:
evidence for one sentence needn’t be evidence for
a sentence extensionally equivalent with it.
People must have talked about this stuff,
but I just don’t know the mainstream epistemology literature
well enough to know where to look.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Credence, graded possibility and weight of evidence]]></title>
    <link href="http://www.seamusbradley.net/blog/blog/2013/01/20/credence-graded-possibility-and-weight-of-evidence/"/>
    <updated>2013-01-20T16:21:00+01:00</updated>
    <id>http://www.seamusbradley.net/blog/blog/2013/01/20/credence-graded-possibility-and-weight-of-evidence</id>
    <content type="html"><![CDATA[<p>Here’s a post that’s actually about philosophy.
The basic idea is that there seem to be lots
of different kinds of “measures on events”
that we can think about.
There are credences,
there are chance functions,
and there are others (about which more later).
I just want to try and identify and distinguish some of these.</p>

<!-- more -->

<p>Let’s start with a puzzle.
The standard axioms of graded belief
require that $b(\top)=1$ where $\top$ is the tautology.
They will also end up requiring that
contingent truth $X$ also gets $b(X)=1$.
So this notion of belief can’t capture the idea that 
$X$ could have been false in a way that $\top$ simply couldn’t.
Not all contingent truths are created equal.
Some contingent truths are surprising,
some are not.
If I roll six dice,
I do not expect to get all sixes.
If I were to do so,
my belief that I got six sixes would be one,
but there’s still a sense in which that outcome was <em>unlikely</em>.
The set of possible worlds where such an event happens
is intuitively small.
Is there some notion of a measure on the set of events
that captures this intuition that some truths are
“more possible” than others?
(I think the idea of chance as “graded possibility” goes back to Leibniz).
I bet we could define some measure $c$ on the set of possible worlds
such that $c$ is a probability measure.
In fact, in another post, I may actually relate a couple of theorems
that would guarantee this (and more!).
Intuitively, $c$ would measure the size of the set of possible worlds
where the event is true.
This measure, unlike credence, would not change in the light of evidence.
It would be
something like the “ur-chances” that Richard Pettigrew talks about
<a href="http://dl.dropbox.com/u/9797023/Papers/chancecrednorms.pdf">here</a>
for example.
We could define a conditional notion of graded possibility in
terms of the measure restricted to the conditioning event.
This would behave like a conditional probability 
(again, theorems in a later post).</p>

<p>So we have credence, and we have this “graded possiblity” which
is something like chance,
but perhaps a bit different
(such a function won’t satisfy 
<a href="http://bjps.oxfordjournals.org/content/58/2/113.abstract">Schaffer’s</a>
requirements for something to play the <em>chance role</em>).
I guess they are going to be related notions
(related by something like Lewis’ Principal Principle
or one of its close cousins),
but they certainly aren’t the same thing.
Here’s a third notion:
“weight of evidence”.
Again, not unconnected from the other notions,
but arguably distinct.
Here’s an example.
I have just rolled six sixes.
The evidence for my having done so is 
about as strong as evidence gets:
direct evidence of my senses.
I still find the fact surprising,
despite having excellent evidence that it is so.
(And my credence in such a thing having happened is one.)
Now my friend tells me he has failed to roll six sixes.
My evidence for such a proposition is weaker –
I have only testimonial evidence –
but the proposition is unsurprising.
So I am inclined to have a high degree of belief in
such an event having occured despite the weakness of the evidence.
What would a formal measure of weight of evidence look like?
Well, Dempster-Shafer belief theory is a better
measure of evidence than it is of belief.
(Shafer’s book was called <em>A Mathematical Theory of Evidence</em>,
after all).
So maybe that’s what it should look like.
But how it should relate to credence seems tricky.
Anyway, others have thought about something like this idea,
like <a href="http://www-personal.umich.edu/~jjoyce/papers/hpre.pdf">Jim Joyce</a>
and <a href="http://mind.oxfordjournals.org/content/114/454/277.abstract">James Hawthorne</a>.</p>

<p>One might think that the weight of evidence thing
is really just captured by your credences in the following way:
the more your credence can be moved by a particular
piece of evidence,
the less your weight of evidence for that proposition is.
That is, weight of evidence is captured by the <em>resilience</em> of your credences.
Maybe.
I’ll have to think about that some more.
I guess the main thing I wanted to get across here
is that there’s more to belief than <em>degree of belief</em>.
That is, there’s more to belief than <em>just</em> the numbers
the belief function assigns to the events.
For example, there are various kinds of structural fact about your
beliefs that you might take to be important 
(like that two events are independent).
I talk about this a bit in my thesis.
(I’m procrastinating to avoid doing my corrections,
in case you’re wondering).
I might talk about another example of this later.</p>

<p>So we have these three notions.
Credence, graded possibility (surprisingness?)
and weight of evidence (or perhaps strength of evidence).
The more surprising a proposition,
the stronger the evidence needs to be to move your credence.
And conversely,
the less surprising a proposition,
the more your credence can be moved by even weak evidence.
I wonder if surprisingness and strength of evidence are enough
to effect a “decomposition” of credence-dynamics.
And if not, what is missing?</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[IFTTT is great]]></title>
    <link href="http://www.seamusbradley.net/blog/blog/2013/01/20/ifttt-is-great/"/>
    <updated>2013-01-20T14:14:00+01:00</updated>
    <id>http://www.seamusbradley.net/blog/blog/2013/01/20/ifttt-is-great</id>
    <content type="html"><![CDATA[<p>This is a very short post just to say that 
<a href="http://ifttt.com/">IFTTT</a>
is a great little service.
I use it to watch the RSS feed for this blog
and tweet when I write a new post.
I’m sure it could be used for all kinds of other fun stuff.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Up-goer five-ing my thesis]]></title>
    <link href="http://www.seamusbradley.net/blog/blog/2013/01/19/up-goer-five-ing-my-thesis/"/>
    <updated>2013-01-19T15:56:00+01:00</updated>
    <id>http://www.seamusbradley.net/blog/blog/2013/01/19/up-goer-five-ing-my-thesis</id>
    <content type="html"><![CDATA[<p>Inspired by a recent 
<a href="http://xkcd.com/1133/">xkcd comic</a>,
people have started to try to explain complex stuff using only the
1000 most common words.
There’s a <a href="https://twitter.com/search?q=%23upgoerfive">hashtag</a>
and everything.
There’s a special <a href="http://splasho.com/upgoer5/">text editor</a> 
that keeps you on track.
Taking time out from the dreaded thesis corrections,
I’m going to try to describe my thesis in this restricted way.</p>

<!-- more -->

<p>So here goes:</p>

<blockquote><p>Sometimes you can not know anything. You don&#8217;t know enough facts to make the things you believe be like people want them to be. I think this means we need a better way to talk about how strong you believe things that lets you have very not strong things you believe that don&#8217;t act in the way people expect.</p><p>I show that the normal way people talk about the way you believe things isn&#8217;t good. They think too many things about how you believe things. When you don&#8217;t think those things about how to believe things you get a new way of thinking about how to believe things. This new picture of how to believe is a bit like the old one, but it is also better.</p><p>Also you use the things you believe to help you pick what things to do. The new picture of how to believe makes picking what to do hard. I talk about this a lot and think about what we want to do with our picture of how to pick what to do.</p><p>I then use this new picture of believing and picking what to do to talk about all the ways we don&#8217;t know what is going on with rain and sun and things like that. This is important because we need to pick what to do, but we don&#8217;t know what the rain and sun will do.</p></blockquote>

<p>It’s rather difficult. I’m sure if I thought about it a bit more I could improve this.
But I don’t think it would help all that much.
I don’t think this actually makes things easier to understand what my project is about.
I’m going to be trying the same thing with my EPSA and BSPS abstracts in the near future.</p>

<p>Here’s a much more successful <code>#upgoerfive</code> attempt.
This time, I was just trying to summarise my research interests.</p>

<blockquote><p>I think about things like how the things you believe fit together. And what we mean when we talk about pictures of what things there are and how they move around.</p></blockquote>

<p>I’m actually quite pleased with that.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[First impressions of Munich]]></title>
    <link href="http://www.seamusbradley.net/blog/blog/2013/01/08/first-impressions-of-munich/"/>
    <updated>2013-01-08T14:51:00+01:00</updated>
    <id>http://www.seamusbradley.net/blog/blog/2013/01/08/first-impressions-of-munich</id>
    <content type="html"><![CDATA[<p>As I mentioned in my last post, I have a post doc position in Munich.
I have now moved to Munich and am gainfully employed as a philosopher.
Here I have collected a couple of first impressions of Munich.</p>

<!-- more -->

<p>One thing I like about Munich is that the architecture is often very impressive.
It’s hard to wander around the city without bumping into huge, impressive,
palatial buildings.
Much of this building is due to the extravagance of the Bavarian
Princes and Kings (who were typically named Ludwig or Maximilian).
The scale and sheer number of these huge constructions is staggering.
London has its tall buildings and its pretty buildings,
but you have to really seek them out:
you don’t tend to just turn a corner and go 
“Wow, that’s a rather large building.” with the same frequency that you do in Munich.</p>

<p>While we’re on the subject, the history of Bavaria is a little confusing.
Basically, the Wittelsbachs were in charge for a good seven hundred years,
and they had the annoying habit of mostly being called Ludwig or Maximilian.
At first they were dukes, then prince electors of the Holy Roman Empire,
then they became a kingdom in 1806.
Now, when they became a kingdom, Maximilian IV Elector of Bavaria
became Maximilian I King of Bavaria.
He was succeded by Ludwig I, Maximilian II and Ludwig II.
This naming scheme does not help work out who build what.
I suppose France had a lot of King Louis, but at least they didn’t 
just arbitrarily reboot the numbering system at one stage.</p>

<p>Another thing that I was surprised to learn is that Bavaria is predominantly Catholic.
I guess because of the fact that Martin Luther was German,
I just sort of assumed that all of Germany became Protestant.
But no, the Duchy of Bavaria fought for the Catholics in the Thirty Years War.
I guess it makes sense since, being the South-Eastern part of Germany,
Bavaria is quite close to (Catholic) Italy.
Incidentally, Austria is also predominantly Catholic.
This also surprised me. 
I guess I just had this idea that German speakers would be predisposed to
Protestantism, but that’s clearly crazy.
Munich’s cathedral is called Frauenkirche,
the Frau in question being the Virgin Mary.
Munich’s main square, Marienplatz, is named after the 
Mariensäule, a marble column topped with a golden statue of Mary holding a 
little baby jeebus.
The marble column’s base has the names of various Popes engraved on it.
Can’t get much more Catholic than that.</p>

<p>People here tend to say “Grüß Gott” rather than “Hallo”.
I’ve also heard people say “Merci” rather than “Danke”.</p>

<p>Without wanting to further propagate any stereotypes about the Germans,
I was struck by how rule-abiding most people are.
Cyclists stop at traffic lights, and they slow down to give pedestrians right of way.
Jay-walking is much less common than it is in London.
On the S-bahn, the doors will open on both sides but the announcer will
have told you which side you should alight from the train:
everybody actually follows the instruction!
When there is a sign that says “no entry”, no one tries to enter!
As someone used to Londoners’ fairly relaxed attitudes to rules of this kind,
the difference is striking.</p>

<p>The rental market is a bit of a nightmare.
I am trying to find a flat and it is not fun.
Estate agents charge anything up to 2.38 months’ rent as their fee.
On top of a deposit amounting to about 2 months’ rent, 
this is a huge upfront cost for renting.
I went to view a room in a shared house,
the viewing felt more like an interview.
It’s a seller’s market, so the current occupant could basically choose
who he wants to live with him.
I hate the uncertainty of not knowing where I’m going to be living,
so this has been a rather stressful few days.</p>

<p>Still, my new colleagues are nice,
and I have only really scratched the surface of the variety of excellent beer
on offer in Munich.
I am also looking forward to collecting my walking boots from London and then
I can take a train into the alps and go walking!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Achievement unlocked]]></title>
    <link href="http://www.seamusbradley.net/blog/blog/2012/12/22/achievement-unlocked/"/>
    <updated>2012-12-22T10:57:00+01:00</updated>
    <id>http://www.seamusbradley.net/blog/blog/2012/12/22/achievement-unlocked</id>
    <content type="html"><![CDATA[<p>Without wanting to toot my own trumpet, as they say,
various things have occurred recently.
If life were a video game, I would be winning at the moment.
Here, in no particular order, are some things that would have earned
me “mad points” in Sim Seamus.</p>

<!-- more -->

<ul>
  <li>I submitted my PhD dissertation which stood at just over 90,000 words.</li>
  <li>I passed my viva with minor corrections.
 Once I’ve finished the corrections, the dissertation will appear on my website.</li>
  <li>I was offered and have accepted a three year postdoc position at LMU’s
 <a href="http://www.mcmp.philosophie.uni-muenchen.de/index.html">Munich Centre for Mathematical Philosophy</a>.</li>
  <li>I have won the Watkins prize.
 Quoting from the announcement on the LSE philosophy news page:
 “The Watkins Prize is given to an outstanding student working in an area related to
 the research interests of Professor John Watkins:
 philosophy of science, political philosophy, decision theory and philosophy of biology.”
 My dissertation chapter on “Imprecise Decisions” was the work in question.</li>
</ul>

<p>So there you have it.
Next up on my to do list is get some darn papers published.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Learning modals]]></title>
    <link href="http://www.seamusbradley.net/blog/blog/2012/11/08/learning-modals/"/>
    <updated>2012-11-08T15:13:00+01:00</updated>
    <id>http://www.seamusbradley.net/blog/blog/2012/11/08/learning-modals</id>
    <content type="html"><![CDATA[<p>Here’s a more or less direct follow up to my last post
on the 
<a href="http://www.seamusbradley.net/blog/blog/2012/10/20/the-epistemology-of-counterfactuals/">epistemology of counterfactuals</a>.
The basic idea is that the same strategy I talked about there
works as a way of learning other kinds of modal claims.
I’m going to take the example of learning about chance claims,
but I think you could make the same argument
<em>mutatis mutandis</em> for physical possibility,
and perhaps for other sorts of modal notions.
I’ll end with a totally off the wall suggestion about
ethics.</p>

<!-- more -->
<p>OK. 
Recall that the basic thrust of my epistemology
of counterfactuals was that <em>somehow</em> we come to 
assess similarity of certain past observational situations
with the current situation, and this notion of similarity across
past-observed-actual-counterparts is evidence for the truth of certain
counterfactual claims we might like to make about the current situation.</p>

<p>In the same way, we might want to say that we <em>somehow</em>
come to fit “chance set-ups” into collectives of similar
past-observed-chance-set-ups, and this is what fixes the values of
the chances of outcomes of such set-ups.
That is, it is observed coin flips that count as the 
collective of relevantly similar set-ups that determines the
chance of the current coin’s chance of landing heads.
In the last post I just glossed over how we get at 
the right notion of similarity.
But in the current case,
there’s a whole literature on how difficult it is
to fix the right collective of relevantly similar set-ups:
this is the reference class problem.
But remember that I’m doing a sort of phenomenological 
reconstruction of the epistemology of modals,
not giving an account of what grounds the truth of modal claims.
So basically I am just going to sidestep the reference class
problem by saying that
humans have some sort of capacity for recognising similarity,
recognising patterns, and so on.
We have managed to learn which kinds of similarity are salient for what
kinds of inference.
To demand a further explanation of how we come
to recognise salient similarity is,
it seems to me, 
the problem of induction in disguise.
By that I mean that I have the same response to both:
“we can just do it, OK?”.
It looks like “green” is a better predicate
for grounding inference about the colour of emeralds than
“grue” is.
It looks like “6-sided fair die throws”
is a better reference class for chance claims
about this dice than “6-sided fair die throws that didn’t land on 4”.</p>

<p>What I’ve said above may seem,
on its own,
to be fairly trivial.
We learn about chances through learning about
the statistics of the reference classes to which the set-ups belong.
And yes, that’s a pretty trivial point.
But as I said at the beginning, the idea is that this is an example
of how we come to learn about modal claims in general.
Seeing the epistemology of chances in this light
allows us to look at what sort of cross-pollination
might be fruitful: 
what ideas and arguments in the chance literature
might have some traction in, say, the literature on
counterfactuals.
One thing to note is that there is,
on this framing of the issues,
a similarity between the problem of 
salient similarity for counterfactuals
and the reference class problem for 
chances.
Both problems stem from there being too many
ways to structure the space of things (counterparts
or chance set-ups)
and not enough constraints on what counts as a legitimate
structuring.
By structuring, I mean here fixing a relation of similarity
or a carving up of the set-ups into reference classes.
Both of these problems, 
it seems, could be solved
if only there were an objective notion
of naturalness or “projectibility”.
Both of these problems aren’t really problems for the epistemology
because we somehow learn to use “good enough” structurings
of the things.
This last point is just as mysterious
as the fact that we successfully make inductions
all the time and manage to be fairly successful in our predictions.</p>

<p>There’s obviously a lot of vagueness in the above few paragraphs,
but I think there is food for thought there.
Now, as promised, here’s the off the wall thought about ethics:
what if deontic modalities are learned about in the same way?
Might we learn what is permissible and what is obligatory
from observing similar actual situations, the agents’ actions
and whether or not they were approved of?</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[I am on flickr]]></title>
    <link href="http://www.seamusbradley.net/blog/blog/2012/11/02/i-am-on-flickr/"/>
    <updated>2012-11-02T16:38:00+01:00</updated>
    <id>http://www.seamusbradley.net/blog/blog/2012/11/02/i-am-on-flickr</id>
    <content type="html"><![CDATA[<p>This is a quick post to say that over the coming weeks I shall
be slowly adding some photos I took to <a href="http://www.flickr.com/photos/scmbradley/">Flickr</a>.
These will, for the most part, be photos that I have already sort
of published in my public album on Picasa.</p>

<p>I will be doing my best to caption and tag all the photos.
What fun.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[The Epistemology of Counterfactuals]]></title>
    <link href="http://www.seamusbradley.net/blog/blog/2012/10/20/the-epistemology-of-counterfactuals/"/>
    <updated>2012-10-20T12:12:00+02:00</updated>
    <id>http://www.seamusbradley.net/blog/blog/2012/10/20/the-epistemology-of-counterfactuals</id>
    <content type="html"><![CDATA[<p>“If I were to let go of this ball, it would fall to the floor” is true and
“If I were to let go of this ball, it would turn into an aardvark” is false.
How do we come to learn about these sorts of constructions?
Everybody and their Mum knows that David Lewis offered an account of the semantics
of these counterfactual conditionals.
But he didn’t offer much in the way of and understanding of 
<em>why</em> we make the intuitive judgements that we do.
Indeed, it was the intuitive judgements of the truth or falsity that Lewis
took as the <em>data</em> that his theory needed to accommodate.
I’d like to try to give some sort of analysis of how we come to 
learn the truth or falsity of certain counterfactuals
using something like Lewis’ analysis of the truth conditions of counterfactuals.</p>

<!-- more -->

<p>Uh-oh!
I’ve been thinking about counterfactuals again.
This is a very rough sketch of an idea I had
a few days ago.
Comments appreciated.
(My comments policy is outlined on the 
<a href="http://www.seamusbradley.net/blog/about/">About</a> page of this blog.)</p>

<h1 id="lewis-semantics">Lewis’ Semantics</h1>

<p>Put very crudely, Lewis’ possible world semantics says that a 
counterfactual of the form $A\Rightarrow C$ is true just in case
all the closest $A$-worlds are also $C$-worlds.
An $A$-world is a possible world where $A$ is true and likewise
for $C$.
What makes it true that “If I were to drop this ball, it would fall to the floor”
is the fact that all the closest possible worlds where
I drop the ball are also worlds where it falls to the floor.
I am actually a creature that inhabits this possible world, 
rather than some other.
So what Lewis’ semantics actually needs is that the closest worlds
where <em>my counterpart</em> drops a counterpart of this ball,
that counterpart drops to (a counterpart of) the floor.
Lots has been written on Lewis’ account of counterfactuals,
questioning many of the concepts I have just appealed to;
counterparts, closeness of worlds, possible worlds themselves.
I am just going to take all this stuff for granted for now.</p>

<h1 id="epistemology-of-counterfactuals">Epistemology of Counterfactuals</h1>

<p>What I am worrying about is this: How did I come to know that this 
particular counterfactual is true?
I have certainly never had any direct epistemic access to other possible worlds.
I don’t feel that I can simply intuit the truth of certain facts
about nearby possible worlds.
There must be things about this world that I have witnessed or been told
about that ground my knowledge of the counterfactual.
But now let’s refocus this question:
how do I come to learn that letting go of a ball means that it
will drop to the floor?
I am going to take it as read that the answer to this question 
is some suitably philosophical elaboration of the following intuitive answer:
“Well, I’ve seen people let go of things before,
and I know what happens to them: 
they fall to the floor (and they don’t turn into aardvarks)”.
In the simplest case, I’ve dropped this ball many times before 
and have observed that it falls to the floor.
But I don’t need to have observed this ball falling to the floor
when dropped to know that it will fall when let go of:
my knowledge that that counterfactual holds true
could well come from my having seen different balls dropped
by other people.
In brief: I have observed counterparts of this ball
subjected to the antecedent of the counterfactual conditional
and observed that the consequent holds true in those circumstances.
This is at once a crude approximation to the basic idea of 
the experimental method, and more generally, the source of much of our 
knowledge of the world.</p>

<p>So the basic idea is this: I have observed counterparts of the situation
described by the antecedent of the counterfactual, 
and have observed that the consequent also holds true in
those situations.
These counterparts inhabit the actual world 
(since that is the world I am equipped to learn about).
What about this counterfactual: 
“If I were to let go of this handrail on the underground,
it would fall to the ground”.
This, presumably, is a false counterfactual.
Now, if previously observed dropped balls counted as counterparts
to the handrail, this analysis would be in trouble.
So presumably there is some sort of “closeness relation” or “salience relation”
that tells you what actual things count as counterparts of the
objects that appear in counterfactuals you learn about.
And hopefully this restriction allows us to rule out the dropped ball
being among those things we have observed that are evidence for
the handrail counterfactual’s truth.
We are giving an epistemology of counterfactuals, 
rather than truth conditions for counterfactuals,
but many of the same elements are appearing.
We have counterparts, and there are certain important relations
that decide which things are salient.
Rather than it being a similarity relation deciding which
worlds are close enough to be salient to the truth of a counterfactual,
we have some metric of salience that decides which past observations
count as evidence for (or against) the truth of a counterfactual.
Presumably one could build a more formal account
of the conditions under which certain observations count
as evidence for the truth of a counterfactual along these lines,
but I don’t feel like doing that, and I feel like it would probably
end up being rather similar to the formal analysis that already exists
for the semantics case.</p>

<p>However, I would like to say something about salience.
Part of learning is working out which sorts of things count as evidence for
which sorts of other things.
It seems silly to say it, but the important respect of salience
that past balls have to the current ball is that they are not attached to anything
that would impede their fall.
Humans are quite good at coming to know which are the salient
aspects of comparison with respect to working out which past experiences
are evidence for the counterfactual in question.
Indeed, in the past people have called these salient aspects of comparison
“properties” and used them to <em>explain</em> the ball’s falling.
I don’t want to do that, but it seems that there’s a neat story to tell
as to the epistemology of properties and kinds in terms
of those properties and kinds that we have successfully used in 
assessing the truth of these “predictive counterfactuals”.</p>

<h1 id="doing-away-with-possible-worlds">Doing away with Possible Worlds?</h1>

<p>Now it seems odd to have our semantics and our epistemology
appealing to thoroughly different kinds of things (possible worlds counterparts
versus actual world counterparts).
Could we perhaps just make the semantics rely on actual world
counterparts as well?
Does this sort of approach run into any difficulties that
the standard Lewisian programme doesn’t?
I forsee difficulties with cashing out counterparthood
and similarity (or salience) but those are also the things
that are hard for the standard picture.
I want to turn this into an argument for a kind of 
“actual-world” ersatzism, but I’m sure that’s already been done.</p>

<h1 id="the-physically-impossible">The Physically Impossible?</h1>

<p>This, of course, only works for counterfactuals
that deal with what’s physically possible.
I have not observed any instances of the laws of nature being otherwise
than they are.
So the account I sketched above can only deal with counterfactuals
where the actual laws of physics hold.
But then, I have much less of a firm idea about why it’s important
to have definite answers to questions about those more far-fetched counterfactuals.</p>

<p>Some “different-physics” counterfactuals
are easy.
Take the counterfactual scheme “If gravity followed an inverse cube law then <em>X</em>”.
This hypothesis or supposition <em>specifies</em> how the laws of nature are
different, and thus working out whether it is true is a matter of
working out whether <em>X</em> follows from the specified alternate physics.
The truth of the counterfactual becomes an exercise in mathematics.</p>

<p>But the stronger response to the criticism that this view of counterfactuals
only deals with the actually physically possible is to argue that other counterfactuals
don’t need to be dealt with.
There are some kinds of counterfactuals where, on this account, 
no observation could give you evidence of their truth.
This seems to me to speak against such counterfactuals having truth values.
If we are being good empiricists, then there are no facts about
things for which there couldn’t possibly be any evidence!</p>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Tumbleweed]]></title>
    <link href="http://www.seamusbradley.net/blog/blog/2012/09/25/tumbleweed/"/>
    <updated>2012-09-25T13:28:00+02:00</updated>
    <id>http://www.seamusbradley.net/blog/blog/2012/09/25/tumbleweed</id>
    <content type="html"><![CDATA[<p>It’s been pretty quiet around here lately.
I handed in my PhD thesis recently.
In the feverish weeks leading up to that event, 
I didn’t have a lot of time for blogging.
In the relatively relaxed week since,
I’ve felt no compulsion to write anything.
I am now back from a 
<a href="http://www.bris.ac.uk/structuralism/closing-conference/">conference in Bristol</a>
and am slowly getting back into working.
I have more half-finished projects than I’d care to count,
so I expect some of them to end up 
making an appearance as blog posts in the near future.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Thesis Statistics: Improvements]]></title>
    <link href="http://www.seamusbradley.net/blog/blog/2012/08/13/thesis-statistics-improvements/"/>
    <updated>2012-08-13T19:07:00+02:00</updated>
    <id>http://www.seamusbradley.net/blog/blog/2012/08/13/thesis-statistics-improvements</id>
    <content type="html"><![CDATA[<p><a href="blog/2012/07/24/thesis-statistics-take-1/">Last time</a>
I wrote a simple script to draw a graph of thesis word count
over time using TeXcount and a git repo.
Here I’m just going to point out a few obvious improvements that
I’ve added to the code in the last couple of weeks.</p>

<!-- more-->
<p>One awkward thing about the previous version of the code was that the
dates for the graph were hard-coded.
It would be better just to use the current date as the end date.
We can get the current date in bash as follows:</p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span /></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
</pre></td><td class="code"><pre><code class="bash"><span class="line"><span class="nv">TODAY</span><span class="o">=</span><span class="s2">&quot;$(date +%Y-%m-%d\ %H:%M:%s)&quot;</span>
</span></code></pre></td></tr></table></div></figure></notextile></div>

<p>So how can we build a bash script to do what we accomplished with
the <code>gwc.gp</code> file and the line <code>gnuplot &lt; gwc.gp &gt; gwc.png</code>?
Well, I learned some neat tricks from 
<a href="http://www.techanswerguy.com/2007/08/scripted-gnuplot-graphs.html">over here</a>
which helped me put together the following:</p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span /></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
<span class="line-number">4</span>
<span class="line-number">5</span>
<span class="line-number">6</span>
<span class="line-number">7</span>
<span class="line-number">8</span>
<span class="line-number">9</span>
<span class="line-number">10</span>
<span class="line-number">11</span>
<span class="line-number">12</span>
<span class="line-number">13</span>
<span class="line-number">14</span>
<span class="line-number">15</span>
<span class="line-number">16</span>
<span class="line-number">17</span>
<span class="line-number">18</span>
<span class="line-number">19</span>
<span class="line-number">20</span>
<span class="line-number">21</span>
<span class="line-number">22</span>
<span class="line-number">23</span>
<span class="line-number">24</span>
<span class="line-number">25</span>
</pre></td><td class="code"><pre><code class="bash"><span class="line"><span class="c">#! /bin/bash</span>
</span><span class="line">
</span><span class="line"><span class="nv">TODAY</span><span class="o">=</span><span class="s2">&quot;$(date +%Y-%m-%d\ %H:%M:%s)&quot;</span>
</span><span class="line">
</span><span class="line">gnuplot <span class="s">&lt;&lt;-finis</span>
</span><span class="line">
</span><span class="line">
</span><span class="line"><span class="s">set datafile separator &quot;,&quot;</span>
</span><span class="line"><span class="s">set terminal png size 900,400</span>
</span><span class="line"><span class="s">set xdata time</span>
</span><span class="line"><span class="s">set timefmt &quot;%Y-%m-%d %H:%M:%S&quot;</span>
</span><span class="line"><span class="s">set format x &quot;%Y-%m&quot;</span>
</span><span class="line"><span class="s">set xrange [&quot;2011-12-03 15:08:00&quot;:&quot;$TODAY&quot;]</span>
</span><span class="line"><span class="s">set style fill solid</span>
</span><span class="line"><span class="s">set key outside right</span>
</span><span class="line"><span class="s">set grid</span>
</span><span class="line"><span class="s">set output &quot;gwc-plot.png&quot;</span>
</span><span class="line"><span class="s">plot &quot;dates.csv&quot; using  8:(\$1+\$2+\$3+\$4+\$5+\$6+\$7) with filledcurves x1 title &#39;Climate&#39;,\</span>
</span><span class="line"><span class="s">&quot;dates.csv&quot; using  8:(\$1+\$2+\$3+\$4+\$5+\$6) with filledcurves x1 title &#39;Decision&#39;,\</span>
</span><span class="line"><span class="s">&quot;dates.csv&quot; using  8:(\$1+\$2+\$3+\$4+\$5) with filledcurves x1 title &#39;Imprecise&#39;,\</span>
</span><span class="line"><span class="s">&quot;dates.csv&quot; using  8:(\$1+\$2+\$3+\$4) with filledcurves x1 title &#39;Probabilism&#39;,\</span>
</span><span class="line"><span class="s">&quot;dates.csv&quot; using  8:(\$1+\$2+\$3) with filledcurves x1 title &#39;Framework&#39;,\</span>
</span><span class="line"><span class="s">&quot;dates.csv&quot; using  8:(\$1+\$2) with filledcurves x1 title &#39;Uncertainty&#39;,\</span>
</span><span class="line"><span class="s">&quot;dates.csv&quot; using  8:(\$1) with filledcurves x1 title &#39;Introduction&#39;</span>
</span><span class="line"><span class="s">finis</span>
</span></code></pre></td></tr></table></div></figure></notextile></div>

<p>As far as I can tell, <code>gnuplot &lt;&lt;- finis</code> basically throws everything
until <code>finis</code> at <code>gnuplot</code>.
Using <code>set output</code> we can specify where we want our output to be.
Note I’ve had to escape all the dollar signs.
There might be an easier way to do this,
but I just find/replaced the dollar sign.
This is pretty much the same settings as before except that
the output is set as an option
and I’ve used the <code>$TODAY</code> variable to make the date range keep up to date.</p>

<p>What about improvements to the word counting script?
Well, it’s pretty crazy that all the commits are word-counted
every time the script is run.
We store most of that information in the <code>dates.csv</code> file,
so can’t we check there for what the last commit we’ve counted
was, and then move on from there?</p>

<p>Yes.
We can.
We used <code>git rev list</code> to list commits to
iterate our word count command over.
So we can use <code>git rev list --since="…"</code> to only list
the commits since the most recent date in <code>dates.csv</code>.
We can get the last date out of <code>dates.csv</code> easily enough:
they’re in reverse chronological order, so we need
the date on the top row, which is in positions <code>$8</code> and <code>$9</code> 
if we use <code>awk</code> to extract it.
So adding in those improvements,
the new git word count file looks like this:</p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span /></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
<span class="line-number">4</span>
<span class="line-number">5</span>
<span class="line-number">6</span>
<span class="line-number">7</span>
<span class="line-number">8</span>
<span class="line-number">9</span>
<span class="line-number">10</span>
<span class="line-number">11</span>
<span class="line-number">12</span>
<span class="line-number">13</span>
<span class="line-number">14</span>
<span class="line-number">15</span>
<span class="line-number">16</span>
<span class="line-number">17</span>
<span class="line-number">18</span>
<span class="line-number">19</span>
<span class="line-number">20</span>
<span class="line-number">21</span>
</pre></td><td class="code"><pre><code class="bash"><span class="line"><span class="c">#! /bin/bash</span>
</span><span class="line">
</span><span class="line"><span class="nv">FILES</span><span class="o">=</span><span class="s2">&quot;introduction.tex</span>
</span><span class="line"><span class="s2">uncertainty.tex</span>
</span><span class="line"><span class="s2">framework.tex</span>
</span><span class="line"><span class="s2">probabilism.tex</span>
</span><span class="line"><span class="s2">imprecise-probabilities.tex</span>
</span><span class="line"><span class="s2">decision.tex</span>
</span><span class="line"><span class="s2">climate-decisions.tex&quot;</span>
</span><span class="line">
</span><span class="line"><span class="nv">LASTGIT</span><span class="o">=</span><span class="s2">&quot;$(awk &#39;NR==1 {print $8,$9}&#39; dates.csv)&quot;</span>
</span><span class="line"><span class="k">for </span>commit in	<span class="k">$(</span>git rev-list --since<span class="o">=</span><span class="s2">&quot;$LASTGIT&quot;</span> development<span class="k">)</span>
</span><span class="line"><span class="k">do</span>
</span><span class="line"><span class="k">	for </span>FILE in <span class="nv">$FILES</span>
</span><span class="line">	<span class="k">do</span>
</span><span class="line"><span class="k">	    </span><span class="nb">printf</span> <span class="s2">&quot;$(git show -s --oneline $commit:$FILE 2&gt;/dev/null |texcount -q -template={SUM} -nosub - ), &quot;</span>
</span><span class="line">	    <span class="c"># printf &quot;$(git show -s --oneline $commit:$FILE 2&gt;/dev/null |wc -w ), &quot;</span>
</span><span class="line">	    2&gt;/dev/null
</span><span class="line">	<span class="k">done</span>
</span><span class="line"><span class="k">	</span><span class="nb">printf</span> <span class="s2">&quot;$(git log -1  --date=iso --pretty=format:%ad $commit) \n&quot;</span>
</span><span class="line"><span class="k">done</span>
</span></code></pre></td></tr></table></div></figure></notextile></div>

<p>Now we need to work out how to get this new word count list to
prepend the new word counts to the top of <code>dates.csv</code>.
The following script shows how to do this.
The trick is to output the new dates to a temporary file,
and then append the contents of the old <code>dates.csv</code> file
to the end of it.
Then we move the temporary file to <code>dates.csv</code>.</p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span /></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
<span class="line-number">4</span>
</pre></td><td class="code"><pre><code class="bash"><span class="line"><span class="c">#! /bin/bash</span>
</span><span class="line">
</span><span class="line">./gwc-git.sh &gt; /tmp/dates.tmp <span class="o">&amp;&amp;</span> cat dates.csv &gt;&gt; /tmp/dates.tmp <span class="o">&amp;&amp;</span> mv /tmp/dates.tmp dates.csv <span class="o">&amp;&amp;</span>
</span><span class="line">./gwc-doplot.sh
</span></code></pre></td></tr></table></div></figure></notextile></div>

<p>So that’s a better word count script.</p>

<p><img src="http://www.seamusbradley.net/blog/images/thesisplot-2.png" title="Thesis plot" /></p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[A reason to be sceptical of the long run defense of expected value]]></title>
    <link href="http://www.seamusbradley.net/blog/blog/2012/08/02/a-reason-to-be-sceptical-of-the-long-run-defense-of-expected-value/"/>
    <updated>2012-08-02T16:48:00+02:00</updated>
    <id>http://www.seamusbradley.net/blog/blog/2012/08/02/a-reason-to-be-sceptical-of-the-long-run-defense-of-expected-value</id>
    <content type="html"><![CDATA[<p>Utility is, by definition, the sort of thing we should be trying
to get the most of.
That’s what utility is: it’s the thing you want to have.
But why should you act to maximise <em>expected</em> utility?
One response to this question is to argue that in
the long run, this strategy is best.
I want to suggest that there’s a reason to be wary of this argument.</p>

<!-- more -->

<p>“Imagine” says the EU proponent “that the decision is
repeated infinitely often.”
OK, there’s already some heavy duty weirdness with
infinitely repeated decisions, but that’s not really my target
today.
Let’s just take this point for granted.
“In the limit, always acting to maximise expected utility
comes out as the best policy.”
This is just the 
<a href="http://en.wikipedia.org/wiki/Law_of_large_numbers">Law of Large Numbers</a>
in action.</p>

<p>“But imagine” responds the recalcitrant anti-EU theorist,
“you have a lottery with a million tickets and the prize is
a million Euros.
The decision is to take the lottery or to take a sure 99 Euro cents.”
It will probably be a long time before the EU theorist’s superior strategy
takes effect.
The lottery option will have a much higher variance 
(indeed, any lottery will have a higher variance than a constant act).
So that EU theorist will spend at least some time floating around underneath 
the constantly growing wealth of the sure-option-taker.
Both agents’ wealth tend to infinity,
but in the limit, the lottery chooser’s average gain is higher.
However, the lottery chooser’s gain is a lot more varied:
sometimes (most times) nothing, occasionally a big win.</p>

<p>But the claim is that eventually the EU theorist will
come out on top, almost certainly.
I don’t think this is a good argument.
Let me show you why.
Consider another lottery where the options are
the two options we had before and a third option:
pay 10 Euro cents and get punched in the face.
This is obviously a terrible idea.
But here’s the deal:
there are other policies
that do as well as choosing the lottery in the limit
that are clearly stupid.
Consider the following strategy:
“Choose the lottery, except on the 7th
repetition. 
On repetition 7,
pay to get punched in the face.”
In the limit, the lottery choices will
wash out any disutility from
getting punched in the face.
Or consider “Get punched in the face 100 times,
then choose the lottery”.
Indeed, any initial segment strategy gets washed out in the long run
provided the long run strategy is to choose the lottery.
Infinity is a funny beast like that.
This seems super weird,
since in practice all we ever accomplish
is some particular initial segment of our infinite strategy;
because, y’know, real agents tend to die.
So the point is that the argument for maximising EU
also justifies these crazy strategies.</p>

<p>The EU fan might respond 
“No, you have to choose the same act each time.”
But this isn’t a particularly convincing response.
First, why should we rule out acts where we can change what we do?
Second, what counts as an act?
Is “If you haven’t been punched in the fact 100 times yet,
do that. Else lottery” an act?
If so, then the objections stands.
If not, why not?</p>

<p>You may have noticed that this objection
relies on the limiting behaviour of the strategy.
But so did the original defense of EU theory,
so I don’t take that to be a criticism of the strategy.
That said, EU theory doesn’t do all that well
with infinities anyway,
so maybe we should have expected trouble.
There’s the famous
<a href="http://plato.stanford.edu/entries/paradox-stpetersburg/">St. Petersburg Paradox</a>
which shows how EU theory doesn’t deal well with infinity.
Then there’s Nover and Hájek’s 
<a href="http://scholar.google.co.uk/scholar?hl=en&amp;q=pasadena+game">Pasadena game</a>
and friends.
These are variations on the theme of the St. Petersburg game
that show how bad things can get.</p>

<p>A version of expected utility theory that might be 
immune to the above criticisms is Mark Colyvan’s
<a href="http://philpapers.org/rec/COLRET">Relative Expected Utility</a> theory.
This is a theory expressly developed to deal with the sort
of problems that St. Petersburg and friends bring up.
It also does well at responding to the line of argument
I was suggesting above:
since the lottery strategy
“dominates” the get-punched-then-lottery strategy,
REU prefers the former.
By “dominates” in this context I mean that if you look at each repetition
of the decision,
the difference in utility between the acts
always favours the simple lottery strategy.</p>

<p>But this isn’t really the end of the story.
Colyvan defends his REU theory by arguing that it is a conservative extension of
EU theory (meaning that they coincide for finite decisions).
But in the current case, EU is on trial,
so we can’t use the REU defense for the infinite case
since that would be circular.
Perhaps we could “kick away the ladder” and try to look
for a first-principles defense of REU.
This doesn’t look promising:
if I am sceptical of maximising probability weighted utility,
I am going to be just as sceptical of having my preference
accord with probability weighted utility differences.
Colyvan’s theory has some extra limitations too:
it only works for pairs of acts
(and probably leads to cyclic preference in some cases
of more than 2 acts).
It also builds in state independence, 
which is a controversial assumption in standard EU theory.
So I don’t think this offers a way out.</p>

<p>Is there a better defense of EU theory?
I can’t think of one off the top of my head.
Answers on a postcard.</p>

<p>This post was inspired in part by reading
Lara Buchak’s 
<a href="http://philosophy.berkeley.edu/file/755/Buchak_Risk_Aversion_and_Rationality.pdf">Risk Aversion and Rationality</a>.</p>

<h3 id="edit">Edit</h3>

<p>Thinking about this a little more I realised that
there is another argument for expected utility theory.
This is the famous representation theorem.
That, however, is a topic for another time.
(I also fixed some typos and changed the phrasing in a 
couple of places.)</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Thesis statistics: Take 1]]></title>
    <link href="http://www.seamusbradley.net/blog/blog/2012/07/24/thesis-statistics-take-1/"/>
    <updated>2012-07-24T18:58:00+02:00</updated>
    <id>http://www.seamusbradley.net/blog/blog/2012/07/24/thesis-statistics-take-1</id>
    <content type="html"><![CDATA[<p>“Hey, I wonder how hard it would be to generate
a stacked graph of the word count of my thesis over time.”
And bang goes an evening.</p>

<!-- more -->

<p>How are we to find a good word count of a
<code>.tex</code> file?
There’s a whole post in this question itself.
For now, let’s just say that we are going to be using
the <a href="http://app.uio.no/ifi/texcount/index.html">texcount</a>
script.
Here is how we are going to be word-counting
our files:</p>

<div class="bogus-wrapper"><notextile><figure class="code"><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
</pre></td><td class="code"><pre><code class=""><span class="line">texcount -q -template={SUM} -nosub $FILE</span></code></pre></td></tr></table></div></figure></notextile></div>

<p>The <code>-q</code> flag suppresses errors which would
otherwise mess up our output,
the <code>-template="{SUM}"</code> flag
tells texcount that we only want the sum
of words in text, headings, footnotes and so on.
The <code>-nosub</code> flag tells <code>texcount</code> not to bother doing subcounts
(how many words in each section).
It doesn’t seem to have any effect on performance,
but better safe than sorry.</p>

<p>How do we find out what the word count
was at some point in the past?
What, you mean you don’t have version control
for your thesis?
I use <a href="http://git-scm.com/">git</a>
to keep track of changes to my thesis.
I can find out what a previous version of a file looked by doing:</p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span /></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
</pre></td><td class="code"><pre><code class="bash"><span class="line">git show <span class="nv">$COMMIT</span>:<span class="nv">$FILE</span>
</span></code></pre></td></tr></table></div></figure></notextile></div>

<p>Obviously, replace <code>$COMMIT</code> and <code>$FILE</code> with 
the name of the commit and the file you are interested in.
So if I pipe this into <code>texcount</code>,
I can find out what the word count was at various past times.</p>

<p>Next, we want to loop over a bunch of different
commits, and get the word count for each previous version of the file.
Here’s how to do that for <code>git</code>:</p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span /></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
<span class="line-number">4</span>
<span class="line-number">5</span>
</pre></td><td class="code"><pre><code class="bash"><span class="line"><span class="k">for </span>COMMIT in	<span class="k">$(</span>git rev-list -n 10 master<span class="k">)</span>
</span><span class="line"><span class="k">do</span>
</span><span class="line"><span class="k">    </span><span class="nb">printf</span> <span class="s2">&quot;$(git show  $COMMIT:$FILE 2&gt;/dev/null | texcount  -q -nosub -template=&quot;</span><span class="o">{</span>SUM<span class="o">}</span><span class="s2">&quot; -), &quot;</span>
</span><span class="line">    2&gt;/dev/null
</span><span class="line"><span class="k">done</span>
</span></code></pre></td></tr></table></div></figure></notextile></div>

<p>We use <code>git rev-list</code> to get us the last 
ten commits from the <code>master</code> branch
and then pipe the output of <code>git show</code> into <code>texcount</code>
for each <code>$COMMIT</code>.
This we output to the terminal with <code>printf</code>.
We also send <code>stderr</code> to <code>/dev/null</code> to avoid
errors cluttering up out output.
There will be errors if you try to <code>show</code> a file from a commit
before the file was created.
This isn’t a problem since then <code>texcount</code> will output <code>0</code>
as expected, so it’s best just to ignore the errors.
Once we get this working, we can get information on all the commits
by removing the <code>-n 10</code> flag.</p>

<p>As well as each word count, we want the <em>time</em> the
commit was made.
We can get that with the following:</p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span /></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
</pre></td><td class="code"><pre><code class="bash"><span class="line"><span class="nb">printf</span> <span class="s2">&quot;$(git log -1  --date=iso --pretty=format:%ad $commit) \n&quot;</span>
</span></code></pre></td></tr></table></div></figure></notextile></div>

<p>Note our previous <code>printf</code> (in the <code>git show</code> line) ends with a comma and then a space.
This means that our output will be <code>wordcount, date</code>.
We’ll want the next record to be on the next line, 
hence the <code>\n</code> explicit newline at the end of this command.</p>

<p>We want to word count for several files,
so let’s work out how to loop over them.
I don’t know much about how bash scripting works,
so I’m pretty much stumbling around experimenting until something seems to work.
The following seems to work.</p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span /></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
<span class="line-number">4</span>
<span class="line-number">5</span>
<span class="line-number">6</span>
<span class="line-number">7</span>
<span class="line-number">8</span>
<span class="line-number">9</span>
<span class="line-number">10</span>
<span class="line-number">11</span>
<span class="line-number">12</span>
<span class="line-number">13</span>
<span class="line-number">14</span>
<span class="line-number">15</span>
<span class="line-number">16</span>
<span class="line-number">17</span>
<span class="line-number">18</span>
<span class="line-number">19</span>
</pre></td><td class="code"><pre><code class="bash"><span class="line"><span class="c">#! /bin/bash</span>
</span><span class="line">
</span><span class="line"><span class="nv">FILES</span><span class="o">=</span><span class="s2">&quot;unavoidable.tex</span>
</span><span class="line"><span class="s2">betterdecisions.tex</span>
</span><span class="line"><span class="s2">milnor.tex&quot;</span>
</span><span class="line"><span class="c"># for FILE in $FILES</span>
</span><span class="line"><span class="c"># do</span>
</span><span class="line"><span class="c">#     printf &quot;$FILE, &quot;</span>
</span><span class="line"><span class="c"># done</span>
</span><span class="line"><span class="c"># printf &quot;\n&quot;</span>
</span><span class="line"><span class="k">for </span>commit in	<span class="k">$(</span>git rev-list -n 5 master<span class="k">)</span>
</span><span class="line"><span class="k">do</span>
</span><span class="line"><span class="k">	for </span>FILE in <span class="nv">$FILES</span>
</span><span class="line">	<span class="k">do</span>
</span><span class="line"><span class="k">	    </span><span class="nb">printf</span> <span class="s2">&quot;$(git show $commit:$FILE 2&gt;/dev/null | texcount  -q -nosub -template=&quot;</span><span class="o">{</span>SUM<span class="o">}</span><span class="s2">&quot; -), &quot;</span>
</span><span class="line">        <span class="c"># printf &quot;$(git show -s --oneline $commit:$FILE 2&gt;/dev/null |wc -w ), &quot;</span>
</span><span class="line">	<span class="k">done</span>
</span><span class="line"><span class="k">	</span><span class="nb">printf</span> <span class="s2">&quot;$(git log -1  --date=iso --pretty=format:%ad $commit) \n&quot;</span>
</span><span class="line"><span class="k">done</span>
</span></code></pre></td></tr></table></div></figure></notextile></div>

<p>I define a list of files.
I don’t know what sort of list structures bash understands,
so I basically worked out by trial and error that putting each file on a line works.
There’s probably a nicer way, but whatever.
I have three files in this example.
Note also the commented out line that pipes the <code>show</code>
to <code>wc -w</code> instead of <code>texcount</code>.
For testing purposes, this is useful,
since it’s <em>way</em> quicker.
Note also the commented out stuff at the top
which would put a header row on your
CSV table.</p>

<p>Now obviously you’ll want to put this in a file
with an appropriate header, e.g. <code>#! /bin/bash</code> or similar
and then run it, and send the output to a file.
I’ll assume the file is called <code>dates.csv</code>.</p>

<p>Here’s a little output from one version of
my <code>dates.csv</code> file.</p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span /></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
<span class="line-number">4</span>
<span class="line-number">5</span>
<span class="line-number">6</span>
<span class="line-number">7</span>
</pre></td><td class="code"><pre><code class="bash"><span class="line">14805, 10867, 2170, 2011-08-22 15:48:04 +0100
</span><span class="line">14805, 10845, 2170, 2011-08-19 16:20:17 +0100
</span><span class="line">14805, 10793, 2170, 2011-08-19 16:04:46 +0100
</span><span class="line">14805, 10669, 2170, 2011-08-15 18:21:13 +0100
</span><span class="line">14805, 10648, 2170, 2011-08-15 12:59:24 +0100
</span><span class="line">14805, 10443, 2170, 2011-08-14 16:25:54 +0100
</span><span class="line">14805, 10443, 2170, 2011-08-14 16:24:57 +0100
</span></code></pre></td></tr></table></div></figure></notextile></div>

<p>Wouldn’t it make more sense to put the date column first rather than last?
Maybe, but I didn’t.
This way you don’t have to worry about trailing commas after the last column,
which is an advantage, I guess?</p>

<p>Anyway.
Now we want to use 
<a href="http://www.gnuplot.info/">gnuplot</a>
to create some funky graphs.
Rather than explain how to build the graph,
I’ll point you to 
<a href="http://freesoftware.zona-m.net/how-to-create-stacked-area-graphs-with-gnuplot/">this post</a>
which shows how to draw stacked charts of the kind we want.
That post recommends pre-processing the data to get it to work,
but it’s much easier to use <code>gnuplot</code>’s built in capacities.</p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span /></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
<span class="line-number">4</span>
<span class="line-number">5</span>
<span class="line-number">6</span>
<span class="line-number">7</span>
<span class="line-number">8</span>
<span class="line-number">9</span>
<span class="line-number">10</span>
<span class="line-number">11</span>
</pre></td><td class="code"><pre><code class="bash"><span class="line"><span class="nb">set </span>datafile separator <span class="s2">&quot;,&quot;</span>
</span><span class="line"><span class="nb">set </span>terminal png size 900,400
</span><span class="line"><span class="nb">set </span>xdata <span class="nb">time</span>
</span><span class="line"><span class="nb">set </span>timefmt <span class="s2">&quot;%Y-%m-%d %H:%M:%S&quot;</span>
</span><span class="line"><span class="nb">set </span>format x <span class="s2">&quot;%Y-%m-%d&quot;</span>
</span><span class="line"><span class="nb">set </span>xrange <span class="o">[</span><span class="s2">&quot;2011-02-05 16:47:32&quot;</span>:<span class="s2">&quot;2011-08-22 15:48:04&quot;</span><span class="o">]</span>
</span><span class="line"><span class="nb">set </span>style fill solid
</span><span class="line"><span class="nb">set </span>grid
</span><span class="line">plot <span class="s2">&quot;dates.csv&quot;</span> using  4:<span class="o">(</span><span class="nv">$1</span>+<span class="nv">$2</span>+<span class="nv">$3</span><span class="o">)</span> with filledcurves x1 title <span class="s1">&#39;milnor&#39;</span>,<span class="se">\</span>
</span><span class="line"><span class="s2">&quot;dates.csv&quot;</span> using 4:<span class="o">(</span><span class="nv">$1</span>+<span class="nv">$2</span><span class="o">)</span> with filledcurves x1 title <span class="s1">&#39;betterdecisions&#39;</span>,<span class="se">\</span>
</span><span class="line"><span class="s2">&quot;dates.csv&quot;</span> using 4:1 with filledcurves x1 title <span class="s1">&#39;unavoidable&#39;</span>
</span></code></pre></td></tr></table></div></figure></notextile></div>

<p>I won’t explain much about this <code>gnuplot</code> configuration, 
but note that you can use <code>$1+$2</code> to get a graph of 
the sum of columns 1 and 2:
this is easier than the pre-processing that the above linked
post suggests.
At least, that’s my opinion.
Save something like the above as <code>gwc.gp</code> or whatever,
and then call <code>gnuplot</code> feeding in this file as input
and telling it where to put the output.
Like so:</p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span /></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
</pre></td><td class="code"><pre><code class="bash"><span class="line">gnuplot &lt; gwc.gp &gt; gwc.png
</span></code></pre></td></tr></table></div></figure></notextile></div>

<p>And that’s about all you need to know to create
a stacked chart of change in word count over time.</p>

<p>Sadly, I didn’t start my git repo when I started writing,
but only some time later.
So I don’t have the gratifying experience of seeing the whole growth of
the thing.
But here’s the final product:</p>

<p><img src="http://www.seamusbradley.net/blog/images/thesisplot.png" title="Thesis plot" /></p>

<p>A word of warning:
the bash script is quite slow.
It takes about 30 seconds to do 3 files on 10 commits.
Or 30 seconds to count 30k ish words 10 times.
Now my actual thesis is approaching 70k words and
there are at least 70 commits.
It takes over six minutes to run.
So if you are going to try this,
use the <code>wc -w</code> line instead
and make sure to limit the number of commits that
<code>rev-list</code> spits out until you’re sure it’s working
as hoped.</p>

<p>How’s that for structured procrastination!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[A Yst Primer: Part II]]></title>
    <link href="http://www.seamusbradley.net/blog/blog/2012/07/13/a-yst-primer-part-ii/"/>
    <updated>2012-07-13T18:31:00+02:00</updated>
    <id>http://www.seamusbradley.net/blog/blog/2012/07/13/a-yst-primer-part-ii</id>
    <content type="html"><![CDATA[<p>Time for part two of the <a href="http://www.seamusbradley.net/blog/blog/categories/yst-primer/"><code>yst</code> primer</a> I started <a href="http://www.seamusbradley.net/blog/blog/2012/07/01/a-yst-primer-part-i/">here</a>.
This time, we will see the basics of using string templates and 
yaml data to generate some funky lists.
I’m going to use a silly example, 
but it should be clear how to make this work for sensible
applications like keeping a list of publications
or what have you.</p>

<!-- more -->

<p>Before we continue, let’s simplify the <code>layout.html.st</code> and
the CSS we inherited from the template site.
Here’s a simpler <code>layout.html.st</code>.</p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span>layout.html.st</span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
<span class="line-number">4</span>
<span class="line-number">5</span>
<span class="line-number">6</span>
<span class="line-number">7</span>
<span class="line-number">8</span>
<span class="line-number">9</span>
<span class="line-number">10</span>
<span class="line-number">11</span>
<span class="line-number">12</span>
<span class="line-number">13</span>
<span class="line-number">14</span>
<span class="line-number">15</span>
<span class="line-number">16</span>
<span class="line-number">17</span>
<span class="line-number">18</span>
<span class="line-number">19</span>
<span class="line-number">20</span>
<span class="line-number">21</span>
</pre></td><td class="code"><pre><code class="html"><span class="line"><span class="cp">&lt;!DOCTYPE html&gt;</span>
</span><span class="line">
</span><span class="line">
</span><span class="line"><span class="nt">&lt;html</span> <span class="na">lang=</span><span class="s">&quot;en&quot;</span><span class="nt">&gt;</span>
</span><span class="line">  <span class="nt">&lt;head&gt;</span>
</span><span class="line">    <span class="nt">&lt;meta</span> <span class="na">charset=</span><span class="s">&quot;utf-8&quot;</span> <span class="nt">/&gt;</span>
</span><span class="line">    <span class="nt">&lt;title&gt;</span>$sitetitle$ - $pagetitle$<span class="nt">&lt;/title&gt;</span>
</span><span class="line">    <span class="nt">&lt;meta</span> <span class="na">http-equiv=</span><span class="s">&quot;Content-Type&quot;</span> <span class="na">content=</span><span class="s">&quot;text/html; charset=UTF-8&quot;</span> <span class="nt">/&gt;</span>
</span><span class="line">    <span class="nt">&lt;link</span> <span class="na">rel=</span><span class="s">&quot;stylesheet&quot;</span> <span class="na">type=</span><span class="s">&quot;text/css&quot;</span> <span class="na">href=</span><span class="s">&quot;$root$css/screen.css&quot;</span> <span class="nt">/&gt;</span>
</span><span class="line">  <span class="nt">&lt;/head&gt;</span>
</span><span class="line">  <span class="nt">&lt;body&gt;</span>
</span><span class="line">    <span class="nt">&lt;div</span> <span class="na">id=</span><span class="s">&quot;wrap&quot;</span><span class="nt">&gt;</span>
</span><span class="line">      <span class="nt">&lt;div</span> <span class="na">id=</span><span class="s">&quot;nav&quot;</span><span class="nt">&gt;</span>
</span><span class="line">	$nav$
</span><span class="line">      <span class="nt">&lt;/div&gt;</span>
</span><span class="line">      <span class="nt">&lt;div</span> <span class="na">id=</span><span class="s">&quot;main&quot;</span><span class="nt">&gt;</span>
</span><span class="line">	$contents$
</span><span class="line">      <span class="nt">&lt;/div&gt;</span>
</span><span class="line">    <span class="nt">&lt;/div&gt;</span>
</span><span class="line">  <span class="nt">&lt;/body&gt;</span>
</span><span class="line"><span class="nt">&lt;/html&gt;</span>
</span></code></pre></td></tr></table></div></figure></notextile></div>

<p>Next, let’s replace that horrible messy CSS folder with this simpler
file:</p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span>screen.css</span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
<span class="line-number">4</span>
<span class="line-number">5</span>
<span class="line-number">6</span>
<span class="line-number">7</span>
<span class="line-number">8</span>
<span class="line-number">9</span>
<span class="line-number">10</span>
<span class="line-number">11</span>
<span class="line-number">12</span>
<span class="line-number">13</span>
<span class="line-number">14</span>
<span class="line-number">15</span>
<span class="line-number">16</span>
<span class="line-number">17</span>
<span class="line-number">18</span>
</pre></td><td class="code"><pre><code class="css"><span class="line"><span class="nf">#main</span> <span class="p">{</span>
</span><span class="line"><span class="k">width</span><span class="o">:</span> <span class="m">45em</span><span class="p">;</span>
</span><span class="line"><span class="k">min-height</span><span class="o">:</span><span class="m">300px</span><span class="p">;</span>
</span><span class="line"><span class="k">float</span><span class="o">:</span><span class="k">right</span><span class="p">;</span>
</span><span class="line"><span class="p">}</span>
</span><span class="line">
</span><span class="line"><span class="nf">#nav</span> <span class="p">{</span>
</span><span class="line"><span class="k">min-height</span><span class="o">:</span> <span class="m">300px</span><span class="p">;</span>
</span><span class="line"><span class="k">margin</span><span class="o">:</span> <span class="m">2em</span><span class="p">;</span>
</span><span class="line"><span class="k">width</span><span class="o">:</span> <span class="m">15em</span><span class="p">;</span>
</span><span class="line"><span class="k">float</span><span class="o">:</span><span class="k">left</span><span class="p">;</span>
</span><span class="line"><span class="p">}</span>
</span><span class="line">
</span><span class="line"><span class="nf">#wrap</span> <span class="p">{</span>
</span><span class="line"><span class="k">width</span><span class="o">:</span> <span class="m">65em</span><span class="p">;</span>
</span><span class="line"><span class="p">}</span>
</span><span class="line">
</span><span class="line"><span class="nt">h1</span> <span class="p">{</span> <span class="k">border-bottom</span><span class="o">:</span> <span class="m">1px</span> <span class="k">solid</span> <span class="nb">black</span><span class="p">;</span> <span class="p">}</span>
</span></code></pre></td></tr></table></div></figure></notextile></div>

<p>This is very much <em>like</em> the earlier messy CSS,
but a lot simpler.
Obviously you’ll want to modify this for your own use,
but it should be easier to modify the simple version than it
was the old multi-file mess.</p>

<p>Onto some new stuff now.
First, let’s add another page to our site.
Open up <code>index.yaml</code> and add a new item:</p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span>index.yaml</span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
<span class="line-number">4</span>
<span class="line-number">5</span>
<span class="line-number">6</span>
<span class="line-number">7</span>
</pre></td><td class="code"><pre><code class="yaml"><span class="line"><span class="p-Indicator">-</span> <span class="l-Scalar-Plain">url</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">index.html</span>
</span><span class="line">  <span class="l-Scalar-Plain">title</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">Home</span>
</span><span class="line">  <span class="l-Scalar-Plain">template</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">index.st</span>
</span><span class="line">
</span><span class="line"><span class="p-Indicator">-</span> <span class="l-Scalar-Plain">url</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">beatles.html</span>
</span><span class="line">  <span class="l-Scalar-Plain">title</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">The Beatles</span>
</span><span class="line">  <span class="l-Scalar-Plain">template</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">beatles.st</span>
</span></code></pre></td></tr></table></div></figure></notextile></div>

<p>Now let’s make <code>beatles.st</code>:</p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span>beatles.st</span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
</pre></td><td class="code"><pre><code class="text"><span class="line"># The Beatles
</span><span class="line">
</span><span class="line">Welcome to my Beatles site.
</span></code></pre></td></tr></table></div></figure></notextile></div>

<p>Running <code>yst</code> should update the site in the <code>site</code> folder.
There should now be a <code>index.html</code> and a <code>beatles.html</code>.
The navigation panel on the left should work to
move between them nicely.</p>

<p>Now things get interesting.
Let’s write some information about the Beatles 
into a yaml file.
Here’s a sample:</p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span>beatles.yaml</span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
<span class="line-number">4</span>
<span class="line-number">5</span>
<span class="line-number">6</span>
<span class="line-number">7</span>
<span class="line-number">8</span>
<span class="line-number">9</span>
<span class="line-number">10</span>
<span class="line-number">11</span>
<span class="line-number">12</span>
<span class="line-number">13</span>
<span class="line-number">14</span>
<span class="line-number">15</span>
<span class="line-number">16</span>
</pre></td><td class="code"><pre><code class="yaml"><span class="line"><span class="p-Indicator">-</span> <span class="l-Scalar-Plain">surname</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">Lennon</span>
</span><span class="line">  <span class="l-Scalar-Plain">forename</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">John</span>
</span><span class="line">  <span class="l-Scalar-Plain">instrument</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">Guitar</span>
</span><span class="line">
</span><span class="line"><span class="p-Indicator">-</span> <span class="l-Scalar-Plain">surname</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">McCartney</span>
</span><span class="line">  <span class="l-Scalar-Plain">forename</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">Paul</span>
</span><span class="line">  <span class="l-Scalar-Plain">instrument</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">Guitar</span>
</span><span class="line">
</span><span class="line"><span class="p-Indicator">-</span> <span class="l-Scalar-Plain">surname</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">Harrison</span>
</span><span class="line">  <span class="l-Scalar-Plain">forename</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">George</span>
</span><span class="line">  <span class="l-Scalar-Plain">instrument</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">Bass</span>
</span><span class="line">
</span><span class="line"><span class="p-Indicator">-</span> <span class="l-Scalar-Plain">surname</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">Starr</span>
</span><span class="line">  <span class="l-Scalar-Plain">forename</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">Ringo</span>
</span><span class="line">  <span class="l-Scalar-Plain">realname</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">George Starkey</span>
</span><span class="line">  <span class="l-Scalar-Plain">instrument</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">Drums</span>
</span></code></pre></td></tr></table></div></figure></notextile></div>

<p>Now, we want to translate this information
into something we can put on the website.
The first thing we need to do is tell <code>yst</code> that we
will want that data for our <code>beatles.html</code> page:</p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span>index.yaml</span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
<span class="line-number">4</span>
<span class="line-number">5</span>
<span class="line-number">6</span>
<span class="line-number">7</span>
</pre></td><td class="code"><pre><code class="yaml"><span class="line"><span class="p-Indicator">-</span> <span class="l-Scalar-Plain">url</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">beatles.html</span>
</span><span class="line">  <span class="l-Scalar-Plain">title</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">The Beatles</span>
</span><span class="line">  <span class="l-Scalar-Plain">requires</span><span class="p-Indicator">:</span>
</span><span class="line">    <span class="p-Indicator">-</span> <span class="l-Scalar-Plain">listname.st</span>
</span><span class="line">  <span class="l-Scalar-Plain">data</span><span class="p-Indicator">:</span>
</span><span class="line">    <span class="l-Scalar-Plain">thebeatles</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">FROM beatles.yaml ORDER BY surname</span>
</span><span class="line">  <span class="l-Scalar-Plain">template</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">beatles.st</span>
</span></code></pre></td></tr></table></div></figure></notextile></div>

<p>Don’t worry about the <code>requires</code> line just yet.
Take a look at the <code>data</code> line.
We read the data from <code>beatles.yaml</code> into something
called <code>thebeatles</code>.
We read in <em>and order</em> the data.
That is, we have ordered the entries by the <code>surname</code> attribute,
and that is the order the items will be printed.</p>

<p>Now, when we want to use that data, 
we can use a slightly more complicated version of the things like
<code>$sitetitle$</code> and <code>$nav$</code> from before.
Let’s move back to <code>beatles.st</code>:</p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span>beatles.st</span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
<span class="line-number">4</span>
<span class="line-number">5</span>
</pre></td><td class="code"><pre><code class="text"><span class="line"># The Beatles
</span><span class="line">Welcome to my Beatles site.
</span><span class="line">The Beatles were:
</span><span class="line">
</span><span class="line">$thebeatles:listname()$
</span></code></pre></td></tr></table></div></figure></notextile></div>

<p>What we have here is a template telling <code>yst</code> to 
read in the data from <code>thebeatles</code>
and then run each entry through the <code>listname()</code> function.
We tell <code>yst</code> that the page requires the <code>listname()</code>
function (that’s what that <code>requires</code> line was for).
This way, <code>yst</code> will know to recreate the <code>beatles.html</code> page if
<code>listname()</code> changes.
Let’s define the <code>listname()</code> function now.</p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span>listname.st</span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
</pre></td><td class="code"><pre><code class="text"><span class="line">
</span><span class="line">- $it.forename$ $it.surname$ $if(it.realname)$ \($it.realname$ \)$endif$ *$it.instrument$*
</span></code></pre></td></tr></table></div></figure></notextile></div>

<p>Note that there’s a blank line at the beginning of this file.
That’s quite important as we’ll see a little later.
So what this function does is tell <code>yst</code> how to
format each item.
We want to output this as a list,
so each item of <code>thebeatles</code> is going to be a list item.
We achieve this by using markdown syntax for unordered lists,
hence the dash.
(We need the blank line so that each new item appears as a new list item
on a new line.)
<code>it</code> is how to refer to the current item.
So <code>$it.forename$</code> tells <code>yst</code> to print the forename attribute of the first item.
Likewise for <code>$it.surname$</code>.</p>

<p>Then comes a clever bit.
We check whether the current item has a <code>realname</code> attribute
using the <code>$if(it.realname)$</code> part.
Only if this comes out as true is the next bit implemented.
This next bit (up to the <code>$endif$</code> prints the
real name.
Neat, huh?
I use this method with my list of papers:
if there is a <code>url</code> attribute, the paper title is a link to the file.
Finally we print the <code>instrument</code> attribute in italics.
Done.</p>

<p>This seems like an incredibly complicated way of generating
a simple list.
But it is also a <em>very</em> powerful way to do so.
We could have had other information on each Beatle
that doesn’t show up here but that appears elsewhere.
Or we could use the same information to display things differently.
Let’s say we wanted a list of Beatles broken down by 
instrument.
(A more serious case would be to group all your talks with the same title).</p>

<p>Let’s go back to the relevant portion of <code>index.yaml</code> now.
We are going to extract the information from <code>beatles.yaml</code> again,
but instead of sorting by surname, we are going to group by instrument.
(We’re also going to require a couple of new files, we’ll
get to that in a minute).</p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span>index.yaml</span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
<span class="line-number">4</span>
<span class="line-number">5</span>
<span class="line-number">6</span>
<span class="line-number">7</span>
<span class="line-number">8</span>
<span class="line-number">9</span>
<span class="line-number">10</span>
</pre></td><td class="code"><pre><code class="yaml"><span class="line"> <span class="p-Indicator">-</span> <span class="l-Scalar-Plain">url</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">beatles.html</span>
</span><span class="line"> <span class="-Error"> </span><span class="l-Scalar-Plain">title</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">The Beatles</span>
</span><span class="line">  <span class="l-Scalar-Plain">requires</span><span class="p-Indicator">:</span>
</span><span class="line">    <span class="p-Indicator">-</span> <span class="l-Scalar-Plain">listname.st</span>
</span><span class="line">    <span class="p-Indicator">-</span> <span class="l-Scalar-Plain">sortinstrument.st</span>
</span><span class="line">    <span class="p-Indicator">-</span> <span class="l-Scalar-Plain">simplename.st</span>
</span><span class="line">  <span class="l-Scalar-Plain">data</span><span class="p-Indicator">:</span>
</span><span class="line">    <span class="l-Scalar-Plain">thebeatles</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">FROM beatles.yaml ORDER BY surname</span>
</span><span class="line">    <span class="l-Scalar-Plain">beatleinstruments</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">FROM beatles.yaml GROUP BY instrument</span>
</span><span class="line">  <span class="l-Scalar-Plain">template</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">beatles.st</span>
</span></code></pre></td></tr></table></div></figure></notextile></div>

<p>You don’t actually have to write the words <code>GROUP BY</code> in capitals,
but I think it helps keep clear what are the keywords <code>yst</code> is looking for.
Now let’s add a new list to the <code>beatles.st</code> page.</p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span>beatles.st</span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
<span class="line-number">4</span>
<span class="line-number">5</span>
<span class="line-number">6</span>
<span class="line-number">7</span>
<span class="line-number">8</span>
<span class="line-number">9</span>
</pre></td><td class="code"><pre><code class="text"><span class="line"># The Beatles
</span><span class="line">Welcome to my Beatles site.
</span><span class="line">The Beatles were:
</span><span class="line">
</span><span class="line">$thebeatles:listname()$
</span><span class="line">
</span><span class="line">By instrument:
</span><span class="line">
</span><span class="line">$beatleinstruments:sortinstrument()$
</span></code></pre></td></tr></table></div></figure></notextile></div>

<p>This follows the same pattern as before.
Now we need to look at what sophisticated clever stuff 
is going on in the <code>sortinstrument()</code> function.</p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span /></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
</pre></td><td class="code"><pre><code class="text"><span class="line">$if(first(it).instrument)$
</span><span class="line">
</span><span class="line">- **$first(it).instrument$$endif$** *$it:simplename(); separator = &quot;, &quot;$*
</span></code></pre></td></tr></table></div></figure></notextile></div>

<p>Now, I have to admit I’m getting to the edge of my understanding of
what’s going on here, so this may be a little bit of
a cargo cult programmer way to do this.
As I understand it, what <code>GROUP BY</code> does is
turn <code>it</code> from referring to a single entry at a time
into something that refers to a list of entries that
share the property we have grouped by.
So <code>first(it)</code> refers to the first item of the list of things sharing the
attribute.
In this case, it would be the first Beatle
having the instrument attribute guitar, say.
The conditional part of this template, then,
does the following:
when we get to a new instrument (when we hit the first
dude with a particular attribute) we add a new list item
and then we write the name of the instrument in bold.
That takes care of getting the instrument names written.
How do we write out the names of the people who have those
instruments?
Like I said, it looks like we have a list of entries
for each possible state of the <code>instrument</code> property.
Well, we already know how to get a list to print:
we run each element through a function.
In this case the <code>simplename()</code> function.
It looks like this:</p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span>simplename.st</span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
</pre></td><td class="code"><pre><code class="text"><span class="line">$it.forename$ $it.surname$
</span></code></pre></td></tr></table></div></figure></notextile></div>

<p>So <code>$it:simplename()$</code> formats each member of the list <code>it</code> 
(remember, <code>it</code> is a list now, because of the grouping).
You could actually replace a small part of the <code>$listname()</code> function
by a call to <code>simplename()</code>. 
I’ll leave that as an exercise.</p>

<p>Now let’s imagine that you remember
a bunch of other people who you want to add to your list
of Beatles (I’m regretting not choosing an example where
it made sense to add a bunch of new items, but bear with me).</p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span>beatles.yaml</span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
<span class="line-number">4</span>
<span class="line-number">5</span>
<span class="line-number">6</span>
<span class="line-number">7</span>
<span class="line-number">8</span>
<span class="line-number">9</span>
<span class="line-number">10</span>
<span class="line-number">11</span>
<span class="line-number">12</span>
<span class="line-number">13</span>
<span class="line-number">14</span>
<span class="line-number">15</span>
<span class="line-number">16</span>
<span class="line-number">17</span>
<span class="line-number">18</span>
<span class="line-number">19</span>
<span class="line-number">20</span>
<span class="line-number">21</span>
<span class="line-number">22</span>
<span class="line-number">23</span>
<span class="line-number">24</span>
<span class="line-number">25</span>
</pre></td><td class="code"><pre><code class="yaml"><span class="line"><span class="p-Indicator">-</span> <span class="l-Scalar-Plain">surname</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">Lennon</span>
</span><span class="line">  <span class="l-Scalar-Plain">forename</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">John</span>
</span><span class="line">  <span class="l-Scalar-Plain">instrument</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">Guitar</span>
</span><span class="line">
</span><span class="line"><span class="p-Indicator">-</span> <span class="l-Scalar-Plain">surname</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">McCartney</span>
</span><span class="line">  <span class="l-Scalar-Plain">forename</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">Paul</span>
</span><span class="line">  <span class="l-Scalar-Plain">instrument</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">Guitar</span>
</span><span class="line">
</span><span class="line"><span class="p-Indicator">-</span> <span class="l-Scalar-Plain">surname</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">Harrison</span>
</span><span class="line">  <span class="l-Scalar-Plain">forename</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">George</span>
</span><span class="line">  <span class="l-Scalar-Plain">instrument</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">Bass</span>
</span><span class="line">
</span><span class="line"><span class="p-Indicator">-</span> <span class="l-Scalar-Plain">surname</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">Starr</span>
</span><span class="line">  <span class="l-Scalar-Plain">forename</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">Ringo</span>
</span><span class="line">  <span class="l-Scalar-Plain">realname</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">George Starkey</span>
</span><span class="line">  <span class="l-Scalar-Plain">instrument</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">Drums</span>
</span><span class="line">
</span><span class="line"><span class="p-Indicator">-</span> <span class="l-Scalar-Plain">surname</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">Orwell</span>
</span><span class="line">  <span class="l-Scalar-Plain">forename</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">George</span>
</span><span class="line">  <span class="l-Scalar-Plain">realname</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">Eric Blair</span>
</span><span class="line">  <span class="l-Scalar-Plain">instrument</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">Dystopian Novel</span>
</span><span class="line">
</span><span class="line"><span class="p-Indicator">-</span> <span class="l-Scalar-Plain">surname</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">Clapton</span>
</span><span class="line">  <span class="l-Scalar-Plain">forename</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">Eric</span>
</span><span class="line">  <span class="l-Scalar-Plain">instrument</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">Guitar</span>
</span></code></pre></td></tr></table></div></figure></notextile></div>

<p>Now all you need to do is run <code>yst</code> and the website has 
incorporated these two new secret Beatles.</p>

<p>Working out how all these little pieces fit together can be a little 
brainmelting, and it can seem like overkill.
In fact, in my case, it almost certainly is overkill.
But I hope to have shown you a little bit of the power of this system.
The beauty is that once you’ve set it up,
you’ll only ever really need to add stuff
to the <code>yaml</code> files and <code>yst</code> will take care of the rest.</p>

<p>I have tarballed up the final version of the <code>basic</code> site
which should more or less match what I’ve described here.
You can get the tarball 
<a href="http://www.seamusbradley.net/blog/assets/basic.tar.gz">here</a>.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[A yst primer: Part I]]></title>
    <link href="http://www.seamusbradley.net/blog/blog/2012/07/01/a-yst-primer-part-i/"/>
    <updated>2012-07-01T11:30:00+02:00</updated>
    <id>http://www.seamusbradley.net/blog/blog/2012/07/01/a-yst-primer-part-i</id>
    <content type="html"><![CDATA[<p>I’m about to roll out a new version of my website,
a version based on John Macfarlane’s excellent 
<a href="https://github.com/jgm/yst">yst</a>.
Yst is a nice little program that takes some <code>yaml</code> data files
(or csv, or SQL) and some templates and builds a static website.
The documentation on the github page is a little spare,
so I thought I’d write an introduction to the program.
This will be super basic, but I hope it will help some people
take their first steps.</p>

<p>This is the first of a projected series of posts on 
yst.
The series will live in 
<a href="http://www.seamusbradley.net/blog/blog/categories/yst-primer/">this category.</a>
I’m writing this more to get clear in my head
what the structure is.
It’s a little confusing at first
because you need quite a few files
working together to get things working.</p>

<!-- more -->

<p>First, what is yst and why would I use it?
Here’s what attracted me to the idea:
I can have, say, my list of publications
or my list of conference talks as yaml data.
I can then use yst to build a CV page for my website.
I can also use yst to generate a <code>.tex</code> file 
for a pdf version of my CV.
This way, I don’t need to make the same edits in two different places when
I give another talk.</p>

<p>Yst uses Pandoc under the hood, 
so you could in theory also generate an
ebook of your CV, or any number of other output formats that
Pandoc supports.
I can’t believe I just used the phrase “under the hood”.</p>

<p>What I am not going to is explain how to install
Haskell, Cabal, Pandoc and Yst.
The instructions on the yst site were enough for me,
and I don’t really know any more about the process
than I learned from reading that page.
So I will jump straight to building a site with yst.</p>

<p>On the yst documentation it recommends running <code>yst create mysite</code>
to generate a sample site for you to play with.
The documentation then goes through some of the cool stuff 
that this sample site demonstrates.
I did this, but I found it a little complicated to get my head around
at first.
So here I’m instead going to start from scratch and build things up very slowly.
The intention here is that we will end up at a point
where you will be able to understand what the sample site is showing off.
Incidentally, the documentation is in the <code>README</code> file in the <code>mysite/</code> directory.</p>

<p>The first thing to do is to move to your new directory
and create a file called <code>config.yaml</code>.
This is the file that yst will look at to work out what’s going on.
Here is the <code>config.yaml</code> that the starter site generates:</p>

<div class="bogus-wrapper"><notextile><figure class="code"><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
<span class="line-number">4</span>
<span class="line-number">5</span>
<span class="line-number">6</span>
</pre></td><td class="code"><pre><code class=""><span class="line">indexfile: index.yaml
</span><span class="line">title: My Website
</span><span class="line">templatedir: .
</span><span class="line">datadir: .
</span><span class="line">filesdir: files
</span><span class="line">layout: layout.html.st</span></code></pre></td></tr></table></div></figure></notextile></div>

<p>The important lines for now are <code>indexfile</code>, <code>title</code> and <code>layout</code>.
The <code>title</code> will appear in the <code>&lt;title&gt;</code> of your website.
You can change it to whatever you like,
but beware the “yaml gotchas” mentioned in the <code>README</code>.
The main page we will need is the <code>index.yaml</code> file mentioned
above.
Let’s make one of them now.
The <code>index.yaml</code> file basically lists all your pages
that will appear on the site.
Here’s a very simple example.</p>

<div class="bogus-wrapper"><notextile><figure class="code"><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
</pre></td><td class="code"><pre><code class=""><span class="line">- url: index.html
</span><span class="line">  title: Home
</span><span class="line">  template: index.st</span></code></pre></td></tr></table></div></figure></notextile></div>

<p>All that’s listed here is the url of the page to make,
the title it should have,
and where its template lives.
Later on we’ll see more complex versions of this scheme.</p>

<p>OK. 
We now need to write <code>index.st</code>.
This will be where the main content of the page is written.
You can basically write this page in markdown.
Here’s my simple example.</p>

<div class="bogus-wrapper"><notextile><figure class="code"><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
</pre></td><td class="code"><pre><code class=""><span class="line"># Welcome to the basic website
</span><span class="line"> 
</span><span class="line">Here is the world's simplest `yst` website.</span></code></pre></td></tr></table></div></figure></notextile></div>

<p>Before we continue, we need one more file.
The <code>layout.html.st</code> file is basically the place
where the html template for the site lives.
Copy the version from the starter site for now.
At this stage, I just want to point out one thing about this.
Look at the <code>&lt;title&gt;</code> tag.
It should say:</p>

<div class="bogus-wrapper"><notextile><figure class="code"><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
</pre></td><td class="code"><pre><code class=""><span class="line">&lt;title&gt;$sitetitle$ - $pagetitle$&lt;/title&gt;</span></code></pre></td></tr></table></div></figure></notextile></div>

<p>This uses string templates to replace the text between
dollar symbols with the right stuff.
So <code>$sitetitle$</code> is the title of the site, 
as set by the <code>title</code> line in <code>config.yaml</code>
and then a dash and then 
the <code>$pagetitle$</code> as set by the <code>title</code> line
of the page in <code>index.yaml</code>.
We’ll see some much cooler examples of string template’s
power later.
Note also that the <code>layout.html.st</code> contains
things like <code>$nav$</code> and <code>$content$</code>.</p>

<p>So you should now have a directory with the following 
files in it:</p>

<ul>
  <li><code>config.yaml</code></li>
  <li><code>index.st</code></li>
  <li><code>index.yaml</code></li>
  <li><code>layout.html.st</code></li>
</ul>

<p>You should now copy the <code>files/css/</code> subdirectory
of the sample site into <code>files/css/</code> of the basic site 
we are creating.
The css is a mess, but it’s easier just to do this
for now.</p>

<p>Running <code>yst</code> inside this directory should
generate a <em>very</em> basic website.
It should generate a folder called <code>site</code> with a file called <code>index.html</code>
(and the css directory).
The <code>index.html</code> file should appear more or less like this:</p>

<p><img src="http://www.seamusbradley.net/blog/images/yst-pic-1.png" title="My first yst site" /></p>

<p>So this is the basic structure of files that <code>yst</code> uses to build a website.
So far, this seems quite a round-about way of doing
something rather simple.
We needed a total of five files just to build a single
page!
(That is, the four listed above, and a css file:
as things stand we actually needed a whole bunch of messy
css files, but that’s not important).
That seems overkill.
But things will make sense when we see the power of 
the combination of yaml and string templates.
Next time, we’re going to see how to use other YAML files
to use some structured data and automagically have it added to our
site.</p>
]]></content>
  </entry>
  
</feed>
