Blog of Sara Jakša

How to Deal with Pain

When we were during attention at Psychology class (another 2016/2017 winter semester course that I took), we also touched on the subject of attention. Because the attention is limited, the best way of dealing with pain would be to start doing things, that require a lot of attention. One of the examples, that was given, was math. And here I mean the math by hand type of things, since (at least for me) this requires a lot more attention than programming the solution on the computer.

I know, that when I am at the dentist office, I generally start creating fanfiction stories in my head, so I don't need to think about the pain. This works for me. I guess reciting songs a person knows by heart would also help.

This strategy can also be used with non-physical pain or with any affective state, that needs attention. Like anger or frustration or something else. Sure, it is hard to stop putting attention on the situation, that one is in, but as soon as being removed from it, putting the attention on something else can help with the feelings.

I guess, this is one way the meditation can help people, since meditation is (also) training of the attention. But I am sure, that even without it, simply putting it on something else, when necessary, can still be helpful.

Promise vs. Contract

Another interesting fact, that I unearthed from my notes was the difference between the promise and the contract. The basic difference is, that in promise, there is no institution behind it, so there are no explicit penalties. While in the contract, there is an institution behind it, so there are explicit penalties hardwired in.

So, dating would be a promise, since breaking it would have no explicit penalties. Sure, the partner can leave you, and the society can condemn you, but none of this is certain, and there is nobody and nothing that will make sure this happens.

On the other hand, in marriage, there are consequences. For example, apparently being unfaithful is illegal (though prostitution doesn't count, for some reason). Getting out of the marriage involved the legal process of separation, which can take a long time, since everything needs to be settled there.

This reminds me a bit of the contracts in the queerplatonic relationships community. Here is one explanation of a contract and something that people can use to make it more explicit. But because these don't have penalties written in, this means that they are more like a promise, and not a contract.

But even with promises, there is pasta sunt servanda, which means, that we are still obliged to fulfill promises, expect if all participants consent to not doing it or it becomes against the law.

Why Copyright is Life + 70 Years

As I was going through my notes from winter semester 2016/2017, I have come across an interesting fact, that I had written down. Apparently, the reason, why the copyright is life + 70 years, is because Walt Disney was afraid Miki Mouse will be used in porn movies.

It is very interesting to compare this to why copyright is used now. I mean, these days, when I hear anything about the copyright problems, it is usually be people just copying the book/movie/music/any other artistic endeavor and offer it for free on the internet. I mean, when I watch the DVDs that I buy, there is usually a warning about copyright. But it is not about misusing the characters or stories, but for privacy. I have to say, that I never checked their website, where they would explain, why this is not a victimless crime.

On the other hand, I read a lot of fanfiction. And I don't remember any huge pressure or debate around there. And their way is much more aligned with the original reason. After all, people take the stories and characters and put them in various positions and scenarios. I am sure, at least some of them would make creators uncomfortable as well. Though, I imagine none of them read the fanfiction of the people, that write about their creative work.

I just find it interesting, so it went from protecting the creative output, to the economical incentives reasoning behind it. :)

Confusion and Embodiment

I have posted, about the connection between perspective and empathy. During the same speech, most of the time was spend on other stuff. One of this was the measurement of confusion. The first point, that she made was, that we are not at detecting confusion from video. But that there were some common patterns. They have tested children during solving mathematical problems and check the confusion at listening to the health information by elders.

These patterns were very simply. People were nodding their hands, when they were understanding or when they were dealing with the simple problems. But they were shaking their heads, when they were confused, or they had to deal with hard problems.

I am right now having interviews with my classmate for his master thesis. So, I have to solve 'simple' tasks, and then we do the phenomenological interviews. What I noticed with myself, using these interviews, but even before, when I was noticing my own experience and when was interviews for another phenomenological study, is that confusion for me has a very particular feeling. I get the feeling in between the eyes and on the forehead, my attention sharpens, I become tenser. If I needed to describe the most likely movement that I would do, would be moving the muscles in between the eyes and on the forehead, and putting the head forward or in a bit rarer case, backward. This movement is a quite different from either the nodding or shaking. But once I give up trying to understand it, then I shake my head.

The giving up happens a lot more frequently in the social situations, then when actually solving 'problems'.

Sadly, I have no idea how other people are experiencing confusion, but for me, it is (at least in part) an embodied experience. So, I don't find it unbelievable, that it is so for other people as well.

Perspective Taking and Empathy

Another note based on the talk that I listened in the cognitive science conference in Krakow. This talk was done by Postma. While it was not a big part of her presentation, I think it was a pretty interesting point.

At one point, at least according to my notes, she was talking about the perspective taking and how it effects empathy. If we imagine others, which means, if we imagine how the other person feels, then we increase the empathy. And I imagine this would mean increasing the altruism and all the other stuff. On the other hand, if we imagine self, so how would be feel in this situation, then this increases the selfishness.

Perspective Description Effect
Other how other person feels higher empathy
Self how would I feel higher selfishness

Inconsistency of Psychopaths

As I am going through my old notes, I have come across my notes from a talk, that I listened at the cognitive science conference in Krakow, given by Nick Novelli.

His talk had been about the application of concepts, that we learn by studying people, to make us more able to design the ethical machines. One of these people were psychopaths, and the other group, based on my notes, was children.

The one thing that he mentioned was, that psychopaths were unable to have a consistent moral system. This is why they appear to misuse the moral terminology and concepts. And why they seem to not get, that their explanations of their actions were inconsistent. So, they would be able to tell, that something is wrong, but they would not be able to apply this to their situations.

Which is quite similar to come of the chat bots that exist (or did exist, I sort of stopped keeping up with the field). Where the conversation would sort of happen, but it would be highly inconsistent. It would not make sense, if a person would spoke with them for some time.

On the other hand, unlike the AI, the psychopaths also have two differences, that are maybe a bit less applicable to the AI. One is the phenomenology, where psychopaths experience emotions differently. The second one is, that the criminal psychopaths (or at least the ones that get caught) seems to have damaged amygdala. Since AI has no qualia, then it does not really make sense to talk about phenomenological experience. And since they don't have brains, they can't have parts of it damaged.

They have the opposite problem of what is the problem with autism. Both psychopaths and autists have problems with one of the empathy components. You can check the table below:

Empathy Description Psychopaths Autists
Cold recognizing emotions Good Bad
Hot feeling emotions Bad Good

The hot empathy is also the reason, why children prefer good puppets and punish bad ones. The psychopaths, on the other hand, reason or guess what other people want. They don't feel it. And if they go wrong or can't keep all of it in head... no wonder they can be inconsistent.

Introverts (Wrongly ?) Think they will Experience Negative Emotions during Socialization

When I was reading scientific articles, I have come across an interesting idea in one of them. They based their work on the notion, that introverts don't become informal leaders, because they think that they will experience more negative emotions because of it. The articles can be found here.

So, the idea is, that introverts think that acting like an extrovert will be negative, even though it ultimately is not. I think it is an interesting idea, and it does have some basis in current theories, but I do think, that in the end, it is a bit limited.

The first idea is, that connection between affect (or emotions) and the big five traits. The extroversion is connected to the positive feelings. But neuroticism is the one that is connected to the negative feelings. So, somebody high on both would feel a lot of both negative and positive feelings, while another that was low on both would not feel any of them as much.

And there is some work done, which showed that number of friends and frequency of contact with others and so on is correlated with higher well-being regardless of level of extroversion. I am trying to remember, if there was any study, that was measuring well-being in the moment of socialization, but I can't remember any from the top of my head.

And I mean, even as an introvert, I do sort of agree. When socializing, I don't feel negative feelings or anything like that. Being in a new group would produce a lot more of thinking, but I would not classify this as the result of socialization, but the result of being in a completely new environment with new rules, that I don't know yet. I mean , it is nice.

What I think this theory ignores are two things: motivation and energy levels.

Nettle in his book Personality has a really good chapter on the extroversion and motivation. How the extroverted people are more likely to pursue new goals, met new people and just do something. While people lower on extroversion don't have a strong drive to simply do something. I also got an impression from reading it, that it has a lot to do with achievement. So maybe instead of simple forecasting of negative feelings, maybe the introverts actually do an affective cost-benefit analysis. They not only predict more negativity, but they also predict less positivity than extroverts. So even if the negative prediction is not true, their corrected cost-benefit analysis still looks quite different.

The second one is the energy levels. When I am socializing, it is like an exercise. Just like a person is tired after the exercise, the same way I can be tired after socialization. Yesterday, I had quite a lot of socialization. So today, I can still feel the effect. I cannot concentrate as much. Doing any kind of high intensity mental work would not happen, if I had to socialize every day.

I am glad that people are researching things like that. And they may be on to something. If there is something that I had learned during my work on a qualitative project is, that I come up with a lot of crack-pot theories and most of them are not right. At least they tested theirs.

Video of my Evolving Music in Python

Well, in my previous blog post, I mentioned that I had a speech about one of my projects. A friend of mine taped me, so here you can watch my speech.

I know I can't, so maybe at least somebody can enjoy it.

Yagni and Minimalism

On the last Python meetup, during one of the presentations, somebody mentioned the acronym YAGNI. I think the whole acronym was not well explained, because I ended up researching it the next day. And I am glad I did.

YAGNI stands for "You aren't gonna need it" and it is a concept in the extreme programming. A short reading about it seems to mean, that implementing a feature because one might need it in the future is a bad idea. The situation can change, and the feature may not be needed, or it may be needed in a different way, that was not predicted. So, there is no point in doing in advance, since it would not save any time.

There is a nasty project that I am technically doing for close to 5 years now. I have notes from it from 2014, and I still did not finish. This is to get rid of all the books that I am never going to read again.

I am a big fan of book and most of my stipend in high school went for buying books. I could spend it all in one visit in the book store. So, I ended up with 100s of books. I have already removed 100s of them, but there were still 4 bookshelves of them left.

I have a system, where I put the books, that I decided to remove on different shelf, and then on a different shelf, when I take their pictures and then on another shelf, when I post them to give away or sell on the internet. After reading about YAGNI, I went to my bookshelf, and now there is less than 1 bookshelf of books left on the pile, where I want to keep them, or I am not decided about it yet. And I could remove more, but the other shelfs started to lose space.

The same problem that I used to have with books, I now have with scientific articles. If I am let on the internet, and I don't know what to do, I can spend around 2 hours on the internet and end up with around 100 new scientific articles to read. And I would usually read around half of them eventually.

Now, that I had read about YAGNI, I have gone over them and deleted quite a lot of them. They were interesting, but they have nothing to do with what I am doing right now. And I can always find them again, if I ever decide to try and research that.

Also, in this could of day, for the first time in years, I have almost no notes in the physical form (not counting the notebooks). And I went over that one file, that I think everybody has, and organized/deleted all the stuff from it. I am talking about that file, where everything is inside. I can maybe also put this in the bin of the things that YAGNI had done for me.

Now, when I look at the thing, I am much more likely to simply delete it or decide that it is not what I need right now. I have no idea, what I am going to need in the future, so I can eliminate all of this. All the wishes of what I could do or what I want to do in the future are no slowly getting erased, in order to make space for something new.

Let’s hope, this is going to push me forward. It would be nice, that in the near future, when I find a job and move away from my parents, that I am no longer bound by my past self and that I manage to either do or eliminate most of my old wishes and projects.

Evolving Music in Python (Tie-In to the Presentation at Ljubljana Python Meetup)

First a bit of a background. I am a cognitive science student, so that means that I study the mind from the perspective of multiple disciplines. Some people do it by studying how we experience things through interviews or descriptive experience sampling (phenomenology) or through the fMRI, EEG, TMS or any other way to measure or influence neural signals (cognitive neuroscience), or doing the work of defining the concepts (philosophy).

The perspective that for me is has the highest interest*skill is computational modeling. I am a lot better at it than any kind of qualitative studies, and it is a lot more interesting than measuring neural data.

So, when I was introduced to the computational modeling in one of my classes, I decided that I wanted to do a more practical project about it. So, when I took the evolutionary algorithms next semester, I sort of knew, that this may be a good opportunity to see, how much a like it.

But the problem was, that I had no idea, what sort of problems could evolutionary algorithms solve at the time. I know that I am interested in the decision making and individual differences, but I could not find any projects using evolutionary algorithms in personality. Any the only ones that I found, that were connected to decision making, were from evolutionary game theory.

So what I did, was ask my professor for ideas. She told me a couple of ideas, but all except one, I would be able to write in python in up to 30 lines of code. The one, that I had no idea, how to attempt, was creating music with evolutionary algorithms.

Which, considering that I am not even listening to music most of the time, may not have been the best idea. Domain knowledge and all of that. I did learn how to play the guitar for 2-3 years, when I was in primary school, but even back there, my teacher had problems with my utter lack of knowledge about what songs exist and which I like. It did not help, that I only took these lessons, because I heard, that it is impossible to become a teacher without playing an instrument. I never took a music theory anywhere.

So, in evolutionary algorithms, there are a couple of thing that are important: the representation, the parameters in the algorithms and the fitness function.

As far as the presentation goes... the standard one is to put the gray representation. It is supposed to be better than binary because of the hamming distance (how many numbers change, when going to the next integer) and more efficient in the use of memory.

The code to change from binary to gray code in below:

def gray_from_binary(number_binary):
    number_binary_list = [int(a) for a in str(number_binary)]
    number_binary_zip = zip(number_binary_list, [0] + number_binary_list[:-1])
    number_gray = [1 if number1 + number2 == 1 else 0 for number1, number2 in number_binary_zip]
    return int("".join([str(n) for n in number_gray]))

But since I had no problems with the memory, I decided to use integers. But then the bigger problem in representation still exist. How to encode music in numbers?

Thankfully, I remembered the lilypond project. Mostly because I use it to store the music that I know how to play in plain text files.

So I took the subset of it. I encoded the piano keys in integers. From c as 1 up to h.

self.notes_to_numbers = {"c": 1, "des": 2, "d": 3, "ees":4, "e": 5, "f": 6, "ges":7, "g": 8, "aes":9, "a": 10, "bes":11, "b": 12, "pause": 13}

The same is for duration. in lilypond the base of 2 is used. So 1 is a whole note, 2 is a half note, 4 is a quarter note,... So, when I needed to make changes, I simply took the exponents and then changed back to the notes. I only encoded the 'normal' notes.

The next is algorithms. There are a couple of things to decide here, but none of them were that interesting. I usually allowed the best x songs in the next stage, and I did the mutation of the duration and the pitch separately. I also made 'children' songs by randomly choosing a place and putting the remaining songs in each children.

The interesting part comes from the fitness function. What criteria was used to choose songs. I did a some tries of my own and I copied two from the scientific articles. That was mostly because, I don't know music theory. I mean, I had to check the what tonality is the first time it was mentioned. But when I started reading about it, I realized that none of it is written from the perspective of understanding music, that could be expressed mathematically.

What I used was checking for repetition of the same pitch or too big of a difference in it, difference in duration, for long notes, too many pauses, and whenever the notes could be given into a single cords.

The ideas that I stole for the papers were the following:

  • The first was the minimal mathematical criteria, that would need to be true, to create listenable piano music by Rodney Waschka
  • The second idea was about how pleasant the notes sound together, which was based on being consonance (harmonic or dis-harmonic) by Bilotta, Pantano and Talarico

Based on my ideas are functions cost_first_try and cost_c_tr, while the function costs based on articles are cost_article2_try1, cost_article2_try2 and cost_article1_try.

def cost_first_try(self, song, final_song=None):
    cost = 0
    #add the cost of two notes repeating the pitch
    cost = cost + sum([1 for note1, note2 in zip(song[:-1], song[1:]) if note1[0] == note2[0]])
    #add the cost of notes having too big of a pitch
    cost = cost + sum([abs(note1[0] - note2[0])**2 for note1, note2 in zip(song[:-1], song[1:]) if not abs(note1[0] - note2[0]) == 1])
    #add cost of notes having too big of a difference in duration
    cost = cost + sum([abs(note1[1] - note2[1]) for note1, note2 in zip(song[:-1], song[1:]) if abs(note1[1] - note2[1]) > 1])
    #add cost of long notes
    cost = cost + sum([1/note1[1] if not note1[1] == 0 else 2 for note1 in song])
    #add cost for cords
    for key in self.keys:
        if set([note[0] for note in song]) in key:
            cost = cost - 20
    return cost

In the first fitness function, I simply included all the ideas that I could think off. I think in this example, my comments tell the story of what I was using pretty well.

def cost_c_try(self, song, final_song=None):
    cost = 0
    #add the cost of two notes repeating the pitch
    cost = cost + 10*sum([1 for note1, note2 in zip(song[:-1], song[1:]) if note1[0] == note2[0]])
    #add the cost of two notes repeating the duration
    cost = cost + 10*sum([1 for note1, note2 in zip(song[:-1], song[1:]) if note1[1] == note2[1]])
    #add the cost of notes having too big of a pitch
    cost = cost + sum([abs(note1[0] - note2[0]) for note1, note2 in zip(song[:-1], song[1:]) if not abs(note1[0] - note2[0]) == 1])
    #add cost of notes having too big of a difference in duration
    cost = cost + sum([abs(note1[1] - note2[1]) if abs(note1[1] - note2[1]) > 1 else 1 for note1, note2 in zip(song[:-1], song[1:])])
    #add cost of long notes
    cost = cost + 20*sum([1/note1[1] if not note1[1] == 0 else 2 for note1 in song])
    #add cost for pauses
    cost = cost + 10*sum([1 for note1 in song if note1[0] == 13])
    #add cost for keys
    cost = cost + sum([25 for note in song if note[0] not in self.keys[0]])
    #add cost for cords
    duration = 0
    current_notes = []
    for pitch, dur in song:
        if dur == 0 and duration != 0:
            cost = cost + 50
        elif dur != 0:
            duration = duration + 1/dur**2
        if dur == 0 and duration == 0:
            duration == 1
        if duration > 1:
            cost = cost + 50
        if duration == 1:
            for cords in self.cords_c:
                if set(current_notes) in set(cords):
                    cost = cost - 10
        duration = 0
        current_notes = []
    return cost

My second try was pretty similar to the first, except, that I added my idea about the cords. My idea was, that if I test all the notes in the certain duration, and if in this duration, the notes can all be put in one of the cords, then this would be good, and it would be the sign of a good music. The idea for this come from the guitar playing with the cords. I don't think it added much to it, but you have an examples to listen to.

My third idea was from the first article, but since this one has horrible convergence, I am not going to go into it.

The forth and fifth ideas were taken from the second article. There the idea was that some notes sound good in combination and some sound bad. So what I did was test two neighboring notes for this.

def cost_article2_try1(self, song, final_song=None):
    #Based on Article: Evolutionary Music and Fitness Functions by E. Bilotta, P. Pantano, and V. Talarico
    cost = sum([1/((self.notes_values[note1[0]] + self.notes_values[note2[0]])/(self.notes_values[note1[0]]*self.notes_values[note2[0]])) for note1, note2 in zip(song[:-1], song[1:]) if note1[0] != 13 and note2[0] != 13])
    #add cost of long notes
    cost = cost + sum([1/note1[1] if not note1[1] == 0 else 2 for note1 in song])
    #add cost for pauses
    cost = cost + sum([1 for note1 in song if note1[0] == 13])
    return cost

The forth one was based on the mathematical formula, that I found in the article. I then added the cost for the pause, because if I would not, then half of the notes would be pauses. This may be because, I skipped testing notes, if one of them was a pause. After that, this was no longer a problem.

def cost_article2_try2(self, song, final_song=None):

    cost = sum([cost_function[note1[0]][note2[0]] for note1, note2 in zip(song[:-1], song[1:])])
    #add cost of long notes
    cost = cost + 20*sum([1/note1[1] if not note1[1] == 0 else 2 for note1 in song])
    return cost

In the last one, I uses the table, that they were using, instead of the mathematical function. But otherwise it was based on the similar principle then the upper one. Since the formatting of this function is not that great, you can also see it here.

Then I simply did a quick gui, because I knew that most people would not know what to do with the script. But in this way, I can actually package it. Not that I would know how to do this for anything else but Arch Linux.

In the last 30s, I wanted to present a sample of music created with one of the fitness functions. Since I did not ended up using computer and I later realized that my speakers are not actually loud. The examples can be found next to the explanation of each fitness function.

For anybody interested in more, the code for this project can be found on my github:

P.S. (added 2018-10-26): A friend of mine taped me, and sent me the video. You can find it here