Computational Spectroscopy

The Great Library of The Rejected Realms.

Moderators: Giangsang, Manson, Delegate

Post Reply
User avatar
frattastan
Posts: 10318
Joined: 02 Jan 2011, 00:00
Discord: frattastan#2205
Location: Soft Underbelly of Europe

Computational Spectroscopy

Post by frattastan »

From http://cityofulthar.wordpress.com/2010/04/03/computational-spectroscopy/, April 03, 2010.
Computational Spectroscopy
By New South Hell (Professor Hell)


Hello students.

You’re probably wondering why, after so many months of inactivity, I have now suddenly scheduled a lecture. It wasn’t my idea, I assure you. But I had a recent chat with the Tenure Committee, and it seems they’re not happy with my work. They don’t think much of my bot research, and they claim that no reputable journal would ever publish it. I’m afraid the word Franken-science was used. They tell me if I want to keep this job, I have to do something respectable. So I’m going to talk to you today about my work in Computational Spectroscopy. It has some nice mathematics in it, which I know will bore you to tears, but it’s not you I’m trying to impress, after all. And, of course, it has no practical value; it certainly won’t help you turn your pathetic little NationStates playgrounds into places where anyone would want to live. But that’s OK too; believe me, to get a paper published, it’s best if it appears to be utterly theoretical. That’s the sort of research that gets into the journals, and sits around unread until twenty years later someone else comes along and figures out how to use it to build really big bombs. And I do like to see things blow up.

When I talk about spectroscopy, I am of course talking about my methodology that derives a thematic spectrum from the issue choices made by a NationStates government. I’ve presented several lectures already on this subject, but they’ve mostly been on the topic of the individual themes and their interpretation. This time, I’m going to talk about how I actually compute the spectrum. To increase your confusion, I’m actually going to present about six different ways of computing a spectrum, all slightly different, and tell you what the advantages of each way are. All the spectra I’ve shown in examples in previous lectures are of the sort I call the Arithmetic spectrum, but as you will see, there are other, perhaps better sorts to choose from.

To start off with, I need to talk briefly about what goes into a spectrum. I have a little database that lists each issue choice, and assigns a numerical value for each theme that is in some way relevant to that choice. You’ve probably seen those silly quizzes (like the ones Da Mayor creates) where you have to answer a bunch of questions like:

1. What is your favorite animal?

(a) kitten
(b) monkeh
(c) vampire kitten
(d) black goat with a thousand young

and when you reach the end of the quiz, it is revealed that “Each question is worth 4 points. Assign yourself 1 point for each (a) answer, 2 points for each (b), 3 points for each (c) and 4 points for each (d). Divide the sum by the total number of points available (which is four times the number of questions), multiply by 100, and you will have your abnormality rating. Use it wisely.”

All of my spectrum techniques with one exception are based on this principle: that each issue has a maximum score for a given theme, and that, to get your rating for that theme, you add up the scores for all the issues you’ve answered, and then divide by the maximum you could have gotten. But there are a number of complications. One is that themes can have negative as well as positive values. In my database, the values range from -4 to +4, where the larger magnitude values generally indicate more extreme positions. Furthermore, the issues are often not very balanced. For instance, there is an issue offering the following three choices: the government should (1) execute adulterers, (2) jail adulterers, or (3) stay out of our sex lives. These choices might have Lib (liberty) ratings of -4, -3 and +1. Because of these complications, instead of having a single divisor when you compute your rating, you have a choice of 2. If the final sum is positive, you divide by the maximum number of points you could have accumulated, but if it is negative you divide by the negative of the minimum. Here’s a quick example. You’ve answered six issues, and we’re computing your Lib rating. Here are the issues, and the points associated with your choices:

Points Max Min
1 4 -1
0 2 -2
-3 1 -3
2 2 0
1 1 -2
2 3 -2


The total is 3, and the maximum you could have gotten is 13, so your score is 3/13, or 23%. Now suppose you changed your answer on issue 6 to one with -2 points. The total is now -1, and the minimum you could have gotten is -10, so your rating would be -1/10, or -10%.

Another consideration is that, if you want this procedure to make any sense at all, the ratings for all the choices have to be comparable. For instance, it would not be very sensible when rating choices for Tuf (violence/toughness) to assign 4 points for allowing concealed weapons but only 2 points for allowing televised human sacrifice. So for each theme there is a rough scale to guide me in assigning points. For instance, for the Dem (democracy) rating, there is the following scale:

+4. Anarchy
+3. Fanatic democracy (e.g., universal referendum, None of the Above)
+2. Participatory democracy (e.g., universal suffrage)
+1. Limited democracy (e.g., suffrage restrictions)
-1. Tentative democracy (e.g., minor restrictions on protest)
-2. Corrupt/failing democracy (e.g., media censorship)
-3. Dictatorship
-4. Brutal dictatorship

The first spectrum I’m going to talk about is very simple. I call it the Uniform spectrum because all the choices a nation makes are treated uniformly. It is nothing more than the technique described above: for each theme, add up the points for all the choices and then divide by the maximum/minimum possible. Let’s talk a little bit about how this works mathematically. For convenience, rather than working with percents, I use a decimal scale in my spectra, ranging from 9 to -9. At any point in the development of a nation, for each issue there are only two numbers we have to rememberfor its rating: n/d, where n is the total points so far, and d is the appropriate denominator (the maximum or minimum number of points possible). Now, we answer a new issue, and our choice gets p points out of m possible. The new score is (n+p)/(d+m), unless n+p has a different sign from n. Something interesting here is that if n/d = p/m, making our choice did not change our rating. But if n/d > p/m, the new rating is closer to p/m than the old one, and the same is true if n/d < p/m. (As we mathematical types like to say, a proof of this is left as an exercise.) One way of thinking about this is that p/m is the “target” of the choice, and that the effect of the choice is to bring the rating nearer to the target.

In particular, if you make a choice worth 1 point, which is the maximum available for that theme and issue, the effect will always be to increase the rating (since it can never be less than one). But if you make a choice worth 1 point when some other choice is worth 4, it will lower your rating whenever it was more than 1/4. And finally, if you make a choice worth 4 points when the maximum is 4, the effect will be again to increase your score, but the total effect will be about 4 times as great as the effect for making a 1 point choice when the maximum is 1. So you can’t work out the effect of a choice without looking at what the other choices do, but you can be sure that making extreme choices will push your score higher (or lower when negative) than making moderate ones will.

It’s also worth noting that your rating can change for a theme even when you make a choice that seems irrelevant to it, provided that some other choice is relevant. For instance, suppose you have a positive rating for Tuf (violence/toughness), and you choose to increase welfare to fight crime. This doesn’t have anything to do with the Tuf theme, but one of the alternatives, flogging criminals as punishment, does. When you make the welfare choice, your Tuf rating will change from n/d to n/(d+2), which will cause it to decrease slightly, or to put it another way, cause it to move closer to the target of 0. If your goal is to be as tough as you can be, then it is reasonable that there is a penalty for making such a wimpy choice.

The Uniform spectrum treats every choice your nation ever made equally. This is fine if you are running a nation that never changes its mind about anything, but what happens if you decide on a change of direction for your nation? For instance, suppose you’ve answered 200 issues as a dictatorship, and now you want to find out what democracy is like. You will have to answer about 400 more issues to turn your Democracy rating around. It will take 200 more issues to get the Dem rating back to 0, and then about 200 more to make it as positive as it was previously negative. NationStates, of course, will recognize that you have become democratic much sooner than that. The main reason that I’ve been researching other ways of computing spectra is to deal with this problem. If your nation is changeable, you probably want a spectrum that gives precedence to your recent issue choices, which is what the other varieties of spectrum seek to achieve.

For the rest of this lecture, I’m going to use one of my nations as an example. I have a number of nations that I call “Mood Swingers,” that are basically ideobots which change their program at random every 150 issues or so. On average, they are quite centrist, but often they become quite extreme by the end of a swing. My example is Mood Swinger 11, which has recently switched from an anarchist mood to an environmentalist mood. Here is the major half of its Uniform spectrum:

Lib +2 Cap +2 Dem +4 Wng -0 Eco +2 Ple -1 Saf -0 Gen -2
Law -2 Own +3 Gov -0 Soc -2 Rel +2 Tuf +2 Mst -3 Evl +3

This spectrum shows that over its whole lifetime, Mood Swinger 11 averages out to pretty moderate, but it doesn’t tell us a whole lot about what it’s been up to lately.

My first idea for how to make the spectrum better for changeable nations was pretty simple, which was to count recent choices more strongly than earlier ones. The way I did this was straightforward. I defined a factor that I mutiplied into the scores, which started out at 1, but which I bumped by 1 every 20 choices. So the first 20 issues used the scores direct from my database, the second 20 multiplied them by 2, the third twenty multiplied them by 3, and so on. I call this the Arithmetic spectrum, because the multipliers went up in arithmetic progression. Mood Swinger 11 has answered about 700 issues now, and so each choice has 35 times the impact of one of the first 20. Here is the major half of its Arithmetic spectrum:

Lib +1 Cap -1 Dem +3 Wng +1 Eco +0 Ple -1 Saf -0 Gen -1
Law -3 Own +1 Gov -0 Soc +0 Rel +3 Tuf +1 Mst -3 Evl +2

While a number of the themes have about the same rating, you can see that Mood Swinger 11 has been significantly more socialist and less capitalist lately than overall.

The Arithmetic spectrum is the one that I’ve been using ever since I started lecturing on spectra. But it nevertheless has a significant disadvantage, which is that it still takes too long for a nation to change its spots. With the Uniform spectrum, if a nation had answered 200 issues, it would have to answer 400 more to change its mind about something. With the Arithmetic spectrum, the number drops to 200, which is better, but still a lot more than it takes for NationStates to work out that your nation has changed.

Now, those of you who didn’t have to follow the link to Wikipedia to learn what an arithmetic progression is have probably figured out what’s coming next. Yes, the next spectrum is the Geometric spectrum, in which the multipliers go up in geometric progression instead of arithmetic progression. To put some numbers on it, every 100 issues, the multiplier doubles. But to make the progression smoother, I use the same grouping as with the Arithmetic spectrum. Every 20 issues, the multiplier increases by a factor of about 1.1487, which is the fifth root of two. This can make a big difference, especially as a nation grows older. As I noted earlier, in computing the Arithmetic spectrum, Mood Swinger 11′s recent issues count about 35 times as much as its early issues. With the Geometric spectrum, the recent issues outweigh the early issues by an impressive factor of 128. Further, as we’ve seen, with the Arithmetic spectrum, if you decide to change your course after answering n issues, you will have to answer about n more to have the change reflected in the spectrum. With the Geometric spectrum, no matter how large n is, after making about 100 more choices, you will be back to neutral, and after 150 you are very likely to have turned things around.

Here is the geometric spectrum for Mood Swinger 11:

Lib +1 Cap -3 Dem +2 Wng +3 Eco -1 Ple -1 Saf +0 Gen -0
Law -2 Own +1 Gov +0 Soc +2 Rel +2 Tuf +1 Mst -3 Evl +2

As you can see, the trend in MS11′s recent choices towards less capitalism and more socialism is even more evident here.

So, now we have the perfect spectrum calculation, right? Well, maybe not. The reason that the Geometric spectrum lets you turn your nation around rapidly is that the effects of choices made earlier fade away rapidly, but this is exactly the source of a different blemish. Have you ever noticed that NationStates will sometimes classify a nation as a Dictatorship even though it has elections, or as a Democracy even though it doesn’t? For instance, my nation Benevolent Despot V has never held an election, and never will, but is now a Capitalist Paradise. In real life, the effects of some decisions linger on forever; in a repressive state, you can’t stop worrying about the secret police just because they were created a long time ago. But using the Geometric spectrum, a decision to have secret police you made 300 issues ago hardly matters at all. A better technique of some kind would make sure that very important choices like that one continued to have a strong effect on your overall ratings, no matter how long ago you made them.

To deal with this problem, I had to do something new. I added on top of the Geometric spectrum a concept of bonus points, which would be added to or subtracted from your rating because of particularly noteworthy past decisions (that have not been overridden). For instance, if you have chosen to have free elections, you get 2 Dem bonus points, while if you have outlawed them, you get -3 or -4 points (depending on whether you’ve started slaughtering the opposition or not). And you can go back to having 0 bonus points for elections if your people are too apathetic to vote at all.

That’s the basic idea. Here are some more details. For most of the themes, there are decisions which award from 1 to 4 positive or negative bonus points for that theme. When it comes time to compute the ranking, you take the maximum number of positive bonus points (or zero if none), and the minimum number of negative bonus points (or zero), and then adjust the rating accordingly for each. My first version of this simply added in the bonus points, but that sometimes caused ratings to go to 10 and beyond. This seemed like a bad thing (it certainly makes it harder to tell whether your rating is extreme or not), so I changed it so that the effect of the bonus tails off the more extreme your rating is without it. An example will help here. Suppose that your nation has both slavery (-4 Lib bonus points) and legal marijuana (+3 Lib bonus points). If your Geometric Lib rating is 0, it will be -1 after both bonuses are applied. But if it is +6, you will only get 1.5 points for legal pot, causing the new rating to be +4 or +3 (depending on what the fractional part of the +6 is). And if it is -6, you will lose 2 points for slavery instead of 4, so that you end up with a -5 rating instead of the -7 you might expect. The idea is that while slavery is highly shocking for a high-Lib nation, for a very negative Lib nation, it kind of comes with the territory.

I call this version of the spectrum the Persistent Geometric spectrum, because it allows the effects of high-impact decisions to persist.

One other thing is worth noting. For this scheme to work, it shouldn’t interfere with your ability to change your nation’s course, or we’ve lost the whole point of the Geometric spectrum. For instance, I would have liked to have assigned Soc (socialism) bonus points when the nation has progressive income taxes, which is the result of several issue choices. The problem is, there is no issue choice to turn off progressive tax rates. It is clear that NationStates interprets some choices as having that effect, because the “and much higher for the rich” line in your national summary can go away. But while a number of issue choices reduce tax rates, it is unclear whether any of them also make taxes less progressive. If I had assigned bonus points for progressive tax rates, then they would persist forever, even if you had reformed your nation to be a heartless capitalist plutocracy.

Here is the Persistent Geometric spectrum for Mood Swinger 11:

Lib +1 Cap -3 Dem +1 Wng +3 Eco -2 Ple +1 Saf -3 Gen -1
Law -2 Own +2 Gov +0 Soc +3 Rel +6 Tuf +3 Mst -3 Evl +2

Comparing this to the Geometric spectrum, we see that the Saf rating has fallen by 3 and the Rel rating has risen by 4, probably the result of legalizing terrorism and having an Inquisition respectively. The Rel rating shows the advantage of the bonus points – I think it is pretty unreasonable that a nation with an active Inquisition gets only a +2 religion rating.

I believe that the Persistent Geometric spectrum produces the best overall results of any of the spectra I’ve developed. And when I give examples of spectra in the future, I intend to use this particular formulation. But there are two more I’d like to present due to their unique properties. These are the Contemporary and Markov spectra.

Return to the Uniform spectrum, which has the problem of not being very good at all for changeable nations. I fixed that by having old choices become less and less important, but another approach is possible. Suppose that, for each issue, we took only the last choice made for that issue into account. That would mean that, if the nation decides to hold elections, any previous decision (for the same issue) to outlaw elections is simply ignored. I call this the Contemporary spectrum, because it emphasizes contemporary decisions.

This is not quite enough, because there are some issues where all the choices are tilted one way. For instance, issue 20 allows you to either ban guns or ban violent entertainment, both of which hurt your Lib rating. If, early on, you chose gun control, but have since become libertarian, there’s no way for you to change your tune on issue 20, since the other choices are just as bad for your Lib. You could dismiss it, but that doesn’t mean you don’t have gun control any more.

I fixed this little flaw by what you might think of as a kludge, which is that whenever you dismiss an issue you previously answered, I cut the impact of the issue in half. My reasoning is that if you were still enthusiastic about gun control, you’d probably choose it again, so dismissing probably means you’re not going to work too hard enforcing the ban. Which means that you can reduce the impact of a particular issue choice on the overall spectrum by dismissing it every time it comes up.

Here is Mood Swinger 11′s Contemporary spectrum:

Lib +2 Cap -0 Dem +4 Wng +1 Eco +0 Ple -1 Saf -0 Gen -2
Law -3 Own +0 Gov +0 Soc +0 Rel +1 Tuf +3 Mst -3 Evl +2

It’s not all that different from MS11′s Uniform spectrum, though it does, like the Arithmetic and Geometric spectra, confirm that right now MS11 is more socialist and less capitalist than it used to be.

But actually, the Contemporary spectrum is much more interesting in the case of unchanging nations, the ones that never change their minds about anything (a group which includes all the bots and most of the other nations I play). The reason is that the only time the Contemporary spectrum changes is when you answer a new issue, or change your mind about an old one. After you’ve answered 200 issues or so, it’s a very rare thing to get an issue you haven’t seen before, which means that if you don’t change, your spectrum doesn’t either. You might call it the Constant spectrum rather than the Contempoorary spectrum. The Uniform, Arithmetic, etc. spectra don’t change very rapidly, but they do change even when the nation’s policies don’t, due to effects of the order in which issues are asked and answered. If what one wants out of a spectrum is a stable view of a nation’s political attributes, I think the Contemporary spectrum is probably the right one to choose.

[Yes, I know I'm yammering on and on, and I'm already way over the time scheduled for this lecture. But don't worry, I have only one spectrum to go, and then I'll have Igor unbolt the doors and you can all have bathroom breaks. Where was I? Oh, yes, the Markov spectrum.]

One thing about the NationStates game is that many nations frequently change their government classification. One of my nations, one of the ones that has been rock steady about answering issues the same way all the time, has probably had all eight government types in the Medium-and-High section of the ideocube. In contrast, all of the spectra I’ve presented up to now are pretty slow about making changes and, once a pattern has been set, don’t make large changes without an idelogical change on the nation’s part. The Markov spectrum is an attempt to go back to first principles of the spectrum to come up with something a little more exciting and dynamic.

Way back at the start of the lecture I noted that, when you make a choice, you’re establishing a target rating for each affected theme, and then moving the actual rating closer to the target rating. What if we got rid of all those numerators and denominators, and just worked with the idea of moving towards the target directly? Here’s what I came up with to do that.

Suppose your current rating for a theme is n, and you answer a new issue with a choice whose score is p points out of a maximum of m. The target of the choice, by our earlier definition, is p/m (times 10, since everything is normally scaled by 10). The value of p indicates how extreme the choice is, and so the choice should move us closer to the target in proportion to the magnitude of p. I decided that if the current rating is 0 and the target is 10, then the new rating should be p. Do a little algebra with that, and you find that the new position after answering the issue should be n+((p/m)-n)*(p/10)). This causes big jumps when you choose something extreme. If you have a Lib of +8 and you legalize slavery, which has a score of -4 for Lib, the impact of this change is 18*0.4, and you suddenly find yourself with a Lib score between +0 and +1. I call this spectrum a Markov spectrum because the way the ratings hop around reminds me of a Markov process.

One little detail I should mention is that if p is 0, the formulas above would say that the rating will not change at all. I feel that even for a zero score, a small amount of change is appropriate, and so I treat a zero score as a small number, 0.25, in computing how much closer to move to the target. In the worst case, a score of 0 can only cause a 0.25 change to your rating, which most of the time is not visible (since I always drop fractions when I print a spectrum). Still, these small numbers do add up, and sometimes you will see a change in the Markov spectrum for making a choice that has nothing to do with the theme in question.

Here is the Markov spectrum of Mood Swinger 11:

Lib -7 Cap -8 Dem -2 Wng +3 Eco -8 Ple +1 Saf +5 Gen +0
Law +2 Own -3 Gov +4 Soc +4 Rel +6 Tuf +4 Mst -4 Evl +1

Now *this* is way different from all the other spectra. The Lib rating is way lower, the Saf rating is way up and the economy is way down. Remember what I said about Mood Swinger 11? It used to have an anarchic ideology, but now it has an environmentalist one. Most of the spectra still show the legacy of the anarchist past of a reasonable level of liberty and a slightly negative level of safety. But the Markov spectrum strongly indicates the liberty, economy and safety levels associated with the current repressive pro-environment ideology. None of the other spectra even come close to this one in telling you what MS11 is up to *right now*.

I am guessing that NationStates itself does something similar to the Markov spectrum when it computes the new freedom rankings for a nation after it answers an issue. The fact that extreme choices can cause big jumps, and the fact that a rating can change due to a seemingly irrelevant choice are both properties often seen in nation behavior. Because it is so sensitive to whatever your nation just did, I consider the Markov spectrum to be the worst of them as far as providing a reasonable national summary. But I’m still pleased to have invented it, due to the insights its behavior gives into the behavior of NationStates itself.

Okay, Igor, you can take the chains off the doors and let everyone out now!

Uh, Igor? Where has he gotten to? I never should have let bob talk me into giving him a job.

Ahem. You may have noticed, students, that the doors to the lecture hall are still bolted. Don’t worry, situations like this were covered in my advanced training long ago at the University of Dis. I know just what to do.

*Professor Hell reaches into his coat, producing a weirdly curved wand, and proceeds to wave it meacingly at the panicking students.*

Students! You are all BANNED for being here listening to this stupid lecture when you could be outside frolicking in the beautiful spring weather. DISMISSIMUS!

*With a smug grin, he looks at the now empty lecture hall. He returns the wand to his coat and sits back waiting for Igor to return and open the doors so he can leave too.*

Appendix for the Really Interested

Here are the themes with issue choices that give you +4 or -4 bonus points. As you can see, in real life, it would be practically impossible to ever forget that these choices had been made:

Lib

+4: Anarchy (in the sense of public disorder, rioting in the streets)
+4: Hard drugs free from the government
-4: Feudalism
-4: Mandatory public nudity
-4: Slavery

Dem

+4: Universal referendum
-4: Brutal dictatorship
-4: Feudalism
-4: Secret police

Own

+4: Feudalism

Gov

+4: Government arranged marriages
-4: Paralyzed government (unanimity required for legislation)

Cap

+4: Industrial slavery
+4: Toxic waste sold as healthful
-4: Industry nationalized

Bus

-4: 100 % taxation

Hea:

-4: Pharmaceuticals banned
-4: Blood transfusion outlawed
-4: Mad @@ANIMAL@@ disease ignored

Cul

+4: Universal coolege education
-4: No public education
-4: Universities closed

Tec

+4: Clone army
+4: People grown in vats
-4: Automation banned

Sec

+4: Military rule
-4: Military abolished
-4: Police force abolished

Nat

+4: Immigrant game show
+4: Total war to defend colonies
-4: Colonial surrender

Law

+4: Plea bargaining disallowed
-4: Anarchy (breakdown of law and order)
-4: Police force abolished
-4: Summary justice

Tuf

+4: Genocide
+4: Gerontocide (killing of retirees)
+4: Public human sacrifice

Cmo

-4: Mandatory public nudity
-4: Population limitation (forced abortion)
-4: Public sadomasochism

Rel

+4: Jehad (war against the infidels)
+4: Public human sacrifice
-4: Religion outlawed

Fam

+4: Adultery a capital crime
-4: Government arranged marriage
-4: Marriage deregulation

Lmo

+4: Guns and police banned
-4: Extermination of the homeless
-4: No aid for starving children

Eco

-4: Industry nationalized
-4: 100 % taxation

Saf

-4: Anarchy (breakdown of law and order)
-4: Prisons abolished
-4: Toxic waste sold as healthful

Gen

+4: Universal college education
-4: Public schools closed
In this world there are two kinds of people: those with loaded guns and those who dig. I dig.
Post Reply

Return to “The Library of Spurned Knowledge”