Search This Blog

Wednesday, December 23, 2020

Book review: Graziano's Rethinking Consciousness

Michael Graziano's Rethinking Consciousness, A Scientific Theory of Subjective Experience [0] is a popular science book where he elaborates in a non-technical way about his attention schema theory and concludes the book discussing implications for artificial intelligence and uploading minds.  During the journey, he explains his materialistic view of what consciousness is.  His definition is that consciousness  is the ability to have a subjective experience.  He explains that through neuroscience, consciousness, or one's subjective experience, arises from the attention schema which constructs a rough simple model of the world which determines what stimuli one's attention should focus on.  This interplay between stimuli, the underlying neural network, and the attention schema creates the feeling that one has a mind or subjective experience.  Consciousness is not an illusion nor is it something non-physical such as a soul or essence, but rather, it emerges from the ingredients similarly to temperature and pressure emerge from the average speed of atoms in a gas in a container.

This first part of explaining the foundation necessary for the attention schema theory and how that theory actually works is somewhat confusing and left me with a feeling that somehow it was all begging the question...the conclusion was somehow assumed in the premises of the argument and it ended up in a big circle.  But the next part speculating on the application to artificial (and given enough technical progress, biological) intelligence is worth the slog.  He posits that there are 4 essential elements to a being that can have consciousness or a subjective experience: (1) be able to pay attention to something; (2) an attention schema that can shift the attention between different things; (3) a wide range of content (memories, data, etc.); and (4) the ability to search the content to find relevant facts on which the attention schema can make decisions to direct the attention.  Following this explanation is a survey of the state of technology (in 2019) to be able to instantiate the necessary pieces to construct an artificial intelligence per this blueprint.  In the discussion, emotional states and body awareness are mentioned as two possible additional necessary elements to arrive at consciousness as we know it.  Graziano speculates these could be added virtually for artificial intelligences, but need more consideration in the biological scenario.

This deconstruction of the necessary elements of consciousness, Graziano suggests, could provide a means to test for it.  Certainly, a computer program that was written to be an artificial intelligence could be examined to see if it in fact fulfilled the requirements.  Biological wetware is harder to examine, but morphological differences between brains would show whether the structures where we currently believe the processes take place are present.  As scanning resolution increases (cue the alien abduction visual), scanning and probing could allow verification that these essential elements are present.  Based on morphology, he asserts that only the higher mammals have consciousness.  One of the consequences of what Graziano proposes is that consciousness is algorithmic.  So, on the question of Searle's Chinese Room paradox, it seems Graziano would argue that the room (not the person within), is conscious. [1]  Thus any Universal Turing Machine can become conscious given the right algorithm and enough data.

The last portion of the book focuses on the possibility of uploading one's mind, whether the Matrix is possible, and the ethical challenges with duplicate "selfs", if such are ever constructed.  While interesting, given how far technology has to go, it remains firmly in the realm of science fiction.

My motivation for reading this book came from discussions on the topic of free will.  Graziano offers no opinion overtly.  The materialistic approach of the explanation suggests he might fall into the determinist camp although he does offer that consciousness is not necessary for decision making [2] and usually, it is argued that consciousness is necessary for free will.  And so, I will end it here and I have Rescher's Free Will [3] on my night stand, borrowed through interlibrary loans from the University of Idaho.  I am in the middle of chapter 1 and already have a lot of reactions to put into words.  (stated that way as a preview of what's to come!)


[0] Graziano, Michael S A. Rethinking Consciousness: A Scientific Theory of Subjective Experience. United States, W. W. Norton, 2019.

[1] https://plato.stanford.edu/entries/chinese-room/

[2] Graziano, p.6

[3] Rescher, Nicholas. Free Will: A Philosophical Reappraisal. United Kingdom, Transaction Publishers, 2009.

Sunday, December 6, 2020

Book Review: Free Will by Sam Harris

 Sam Harris' Free Will [0] is a thin volume (one of the jacket blurb mentions 13,000 words) that is easily digested in an afternoon.  He sets out to show that two assumptions are false: "(1) that each of us could have behaved differently than we did in the past, and (2) that we are the conscious source of most of our thoughts and actions in the present."  Both of these are approached from a neuroscience perspective.  Neuroscience has made progress in mapping conscious and unconscious mental states and processes to physical brain states and changes. [1] Some of this comes from analysis of people with brain injuries. [2]

Examining through introspection, it seems that the thoughts that occur are self-generated.  The way thoughts appear to ourselves is highly suggestive that we have free will.  However, since much of what happens in the brain is not accessible to introspection and we know that some of the heuristics used by the brain can be easily manipulated [3], the introspective conclusion is suspect at best.  For example, having sat on the beach observing carefully for ideas for next year's sandcastle building competition, one would also notice the movement of the sun over the course of the day and conclude that the sun moves around the earth.  But of course this is an illusion.  Physiologically, Harris argues, the conscious thoughts and decisions come from the unconscious which has been ultimately influenced by externalities and therefore no thought or decision can truly be created ex nihilo.

The question that arises here is whether the existence of prior influences are sufficient that thoughts and decisions are pre-determined or is there room for a person to have bechaved differently in a given situation. A die thrown with a certain velocity and spin onto a specific surface will stop with the same number on top under Newtonian mechanics.  That we may not be able to predict it because we do not know the specific values of the velocity or spin does not negate the fact that repeating the throw exactly will not alter the result.  The sources and effects of the pre-determining influences on our thoughts are vast and diverse so as to make it currently impossible to determine.  (Although, one might consider "psychohistory" envisioned in Asimov's Foundation series as a basis for a methodology. [4])

The definitive experiment would be to run time forward and backward over some point in time to see if indeed one behaved differently.  Again, under Newtonian mechanics as well as Einstein's relativistic mechanics, outcomes are pre-determined and therefore would never vary although they may be difficult to compute.  Quantum behaviour, such as where an electron will hit a screen after passing through a double slit, is not pre-determined although there are regions where the probability is zero.  For the regions with non-zero probability, there is no calculation made or process used that can narrow the result a given trial any further than the computed probability density.  For many, this has given hope that if the physiological mechanics occur at scales sufficiently small that quantum effects can result in different outcomes for the same set of inputs, then a physiological basis for free will is established.  Unfortunately this may be a pyrrhic victory in that one does not consciously think and decide upon a course of action, it is merely chosen for us through the arbitrary collapse of a wave function somewhere amongst the myriad of neurons in one's brain.

Another argument that gets raised is the emergent complex behaviour of simple systems such as, for example, cellular automata [5]: the "self" that thinks thoughts and decides decisions is something arising out of the complexity of the neural network in the brain and is distinct from the underlying substructure.  But this emergent behaviour is not something that exists of itself and is merely pareidolia no more autonomous than the patterns of dots occurring in the cellular automata simulation.  Of course there is a difference between simple cellular automata and a human brain in that the brain does exhibit the ability to learn and change behaviour based on this learning.  But learning should not be mistaken for free will, it is an improvement in the ability to predict outcomes and thus is another input into the calculation of what is next thought or decided.

Harris dismisses the compatibilist view as simply a post hoc justification of what has occurred which does not substantiate that an alternate history could have happened.  When it is asserted that someone or something, other than the self, has free will, this is based on observation that it behaves in ways that are self-generated, goal-seeking, and non-uniform in response the same stimuli.  However, rule-basead "artificial intelligences" such as computer opponents in various games also display these traits as do most animals.  Assertions about free will are about interior states not amenable observation and where self-reporting is suspect as explained above.  As a result, when discussing the past, at best one can provide an enumeration of roads not taken, and when discussing the future, it devolves into an analysis of constraints on free action.  Far from making the case for free will, it is not even wrong.

Thus Harris succeeds in his argument for determinism and concludes with some discussion on the implication that people are not the authors of their actions.  Since much of morality considers the intent to cause harm a prime consideration as to the morality of an act, does determinism make morality irrelevant.  Harris argues that it does not make morality irrelevant but rather it suggests that punishment does very little (except in a Pavlovian sense) to deter unwanted behaviour.  Determining desired and undesired behaviours (i.e. what is moral vs. immoral) does not change whether people have free will.  However, how justice is meted out must change once you accept that people do not have free will.  While containment of dangerous persons and deterrence through the threat of punishment is necessary for the greater good, rehabilitation should be the focus rather than incarceration as punishment.

The persistence of the illusion of free will is not difficult to explain.  Human beings tend to give themselves credit for good things and blame bad things on externalities.  When someone achieves a goal or completes a project or provides for their family or community, these good things are attributed as achievements of the self, including that they are self-generated, innovative, or even brilliant solutions to problems that others have failed to solve.  The credit is then given to the conscious self because of the physiological reaction of good feeling that follows.  Bad things that happen are blamed on externalities because if one admits the harm done, if often results in a physiological reaction of bad feeling.  Whether good achievements are self-generated or are the results of externalities does not diminish their good.  The key here about bad things is that humans do have a capacity to learn which can lead to a change in behaviour in a future similar situation.  This learning comes from the sum influences on the individual and is not a function of some illusory free will to learn.


References:

(0) Harris, Sam. Free Will. India, Free Press, 2012.

(1) https://www.thebigq.org/2020/11/26/what-are-some-of-the-key-developments-in-cognitive-neuroscience-%E2%96%B6/

(2) Ananthaswamy, Anil. The Man Who Wasn't There: Tales from the Edge of the Self. United States, Dutton, 2016.

(3) Judgment Under Uncertainty: Heuristics and Biases. Spain, Cambridge University Press, 1982.

(4) Asimov, Isaac. Foundation. United States, Random House Publishing Group, 2004.

(5) https://lifeinbeaverton.blogspot.com/2019/01/python-version-of-game-of-life-cellular.html

Saturday, October 3, 2020

Time series on Oregon State Rep and Senator

 So I have calculated the gerrymandering co-efficient for Oregon State Representatives and Oregon State Senate for the years from 2002 to 2018.  The co-efficient is stable for the State House of Representatives and does show that the re-districting resulting from the 2010 census had some effect in 2012.  The coefficient for the Oregon State senate is unstable.  One of the issues here is that approximately half of the senate seats are voted on every 2 years with possibly some special 2 year terms to replace vacancies.



Saturday, September 19, 2020

More on gerrymandering

 I have done some analysis on the variance between the popular vote vs. seats held in a legislative body for a few states across the 2018 and 2016 elections.  I've tries to find if I can download the data in some format and while some of the states do provide some files that can be downloaded, it has been easier to create a spreadsheet and enter the values myself.  As a result it is rather slow to develop the data, but already, for comparison I have found a few interesting results.  See the graph below (made with matplotlib, let me know if you are interested in the code).  This plots a number of elections with the Kg coefficient that I have calculated on the x-axis and the number of seats in the legislature on the vertical axis.  For the state senates, I have used the number of seats in the senate even though generally only half the seats are up in any general election.  Then I plotted 2 lines.  The green line is where the marker would be if the overall Kg reflected a variance of 1 seat between the popular vote and the seats held.  The yellow line is where the marker would be if the Kg reflected a variance of 2 seats.

Graph of elections

Some of the interesting things that we see here is that most legislative bodies seem to reflect some bias.  This does not identify which party benefits.  It just identifies if there is a bias.  Some bodies do have a pretty high level of bias.  For a number of these bodies I included a point for 2016 as well as 2018.  The direction of change cannot be predicted and seems to be a function of what motivates voters to go vote more than a function of the map.  While setting up a map overall can tilt the playing field, judging on the change in Kg from election to election, shows that migration, candidate quality and voter motivation can all influence the results, for example note the movement of the Idaho Senate and House between 2016 and 2018.  One moved in the direction of more gerrymandering and the other in the direction of less.  In compiling the statistics, I was struck by how many districts (about 20%) only had a single candidate.  This kind of situation clearly depresses voting based on the results that were reviewed.  In a district where there were multiple candidates, the number of votes cast was in some cases double.  For example, in Oregon, when there was only 1 candidate the number of "other" votes, typically write-ins and possibly spoilt ballots, was 10 times when a candidate from both the democratic and republican parties was on the ballot.
The next thing I am going to investigate is the change over time of the Oregon House and Senate, especially if I can see if there was a marked change as a result of the decennial redistricting.


Tuesday, September 15, 2020

Definition of a Gerrymandering coefficient using Oregon voting data 2012-2018

Abstract

Drawing of the lines of electoral districts is difficult work.  It is also one where an advantage can be built in systematically to favor a political party.  This systematic bias is called gerrymandering.  It creates a difference between the aggregate vote for each party and the number of seats held in a legislative body by each party.  It can be done in multi-party or two-party systems.  We will briefly look at some previous work that has been done to measure the level of gerrymandering.  This post introduces a way to quantitatively compare the level of gerrymandering by way of calculating a gerrymandering index [Kg] to be able to compare different jurisdictions.  In the USA, since district lines are drawn by a state body, it makes sense to look at this at the state level.  We will calculate the Kg for Oregon across a number of different elections and draw conclusions about the fairness of how the district lines are drawn.

Theortical considerations

An assumption of a fair electoral system is that the population, as a whole, gets a legislative body that closely mirrors the overall vote for the various parties that were running representatives.  This is represented by equation (1).







Where Vtotal is the total number of ballots cast in the election, Vi is the number of ballots cast for party i, Stotal is the total number of seats in the legislature, Si is the number of seats won by party i.

We can calculate the difference between the actual result in the proportion between parties and the theoretical result as shown in equation (2)

In the case where there is perfect agreement between the aggregate vote totals for each party and the number of seats won, this value is close to zero.  The maximum value is n, the number of parties.  One of the limitations is that the number of seats being considered is a small integer and as a result there is not a level of granularity to be able to get Kg smaller than n/2Stotal.

Previous work that has been done on this topic include:

https://www.washingtonpost.com/wp-srv/special/politics/gerrymandering/

http://www.svds.com/gerrymandering/

One of the metrics used in the previous research is "squiggliness" of the borders of districts where they are compared based on the variance from regular shapes.  I think this is unrealistic.  Borders and coastlines are ragged in many places and population density varies.

The Silicon Valley Data Science site has aged data and it is calculated for only the 2012 general election.  But it does use a similar methodology to determine the discrepancy between the number of seats vs. proportion of the vote on a state by state basis as overall nationally.  (It reports nationally, that for the US house of representatives, the republicans have 17 more seats than proportional representation would award them on a national scale but when considered on a state by state basis, the discrepancy is only 4 seats in favor of the republicans.)

Analysis of Oregon voting and results

I've calculated the Kg for the US house seats in Oregon, the Oregon Senate seats and the Oregon House seats based on data obtained from the Oregon Secretary of State for the 2012 through 2018 elections.  The total number of votes for Democratic candidates was summed.  Similarly for Republicans and finally, all of the other candidates as well as write-in votes was totaled for a third category.  Then the seat allocation by party was compared with the proportion of the overall vote.  From the difference in this comparison, the coefficient Kg was calculated.  The results are summarized in the graph below.

Conclusion and reflection

The US house races have the highest Kg values due to the small number of seats.  There isn't really any specific time trend in the values.  As you might imagine the imbalance was mostly in the Democrats favor, but in one case, the imbalance was in favor of the Republicans.  Comparing the US house vs. OR senate vs. OR house, it seems that the OR senate districts have the least amount gerrymandering since with 30 seats, you would expect higher values than the house, which has 60 seats.  More data needs to be gathered.  Analysis of years prior to 2012 will give insight as to whether the redistricting after the 2010 decennial census tilted the political field or not.  Analysis of other states will help calibrate the interpretation of Kg for the number of districts being considered.

In terms of seats, the US house of representatives is actually 1 seat in favor of the democrats.  The Oregon House of representatives is tilted 4 or 5 seats in favor of the democrats.  However the Oregon Senate has changed over time having 1 or 2 seats in favor of both parties at different times.

Having delved into this data so deeply has made me realize how simplistic the representation of Oregon as a Democratic haven is.  There are some areas that are have a large majority of supporters of one of the parties, but there are in fact a lot of areas which are quite close and the "Other" vote total was greater than the difference between the democrat and republican candidates.  Since the collapse of the center and the proliferation of litmus test issues, it does raise serious questions how government can be made to work to find compromises between the two factions and avoiding the tyranny of the majority.

Friday, September 11, 2020

We need a Universal Borrowing Privilege for all Oregon Libraries

Knowledge is power.  Libraries, especially free public libraries, are a source of knowledge and we need to do everything possible to encourage their use.  I am advocating that Oregon adopt a Universal Borrowing Privilege similar to the one in place in California.  Effectively, this allows every Oregon resident of a district which has a public library to be able obtain borrowing privileges from any other Oregon public library.  Since many of the resources loaned by libraries are now electronic, allowing residents to get library cards at other libraries can smooth out demand for electronic resources.  Also, if you happen to live on the edge of a jurisdiction, this would make it possible to access the library closest to you if it happened to be in another jurisdiction.  Further, this can allow a library to justify establishing a narrowly targeted collection since this now may be accessed by all Oregon residents.  Already, the Inter-Library Loan system does something similar with physical books and a number of libraries have established reciprocity agreements amongst themselves.  The proposed change would simply make these reciprocity agreements universal across all of Oregon automatically.  This can be simply enacted by adding to ORS section 357 wording similar from California Law Sections 20204 and 20205, with just a couple of editorial change, reproduced below:


ยง20204: (a) Public libraries participating in direct loan programs under this Act shall not charge any fee to non residents for borrowing privileges.

(b) Reserves and interlibrary loan requests shall be accepted by the participating public library under the same rules and policies applied to local residents.

(c) All procedures governing registration of borrowers shall apply equally to residents and non-residents.

(d) All materials normally loaned by a participating public library are available for loan to non-residents under the same rules and policies applied to local residents.

(e) All loan and return rules governing circulation apply equally to residents and nonresidents. If overdue material are returned to a library other than the library from which borrowed, fines may be paid to and retained by the library to which the return is made. Payments for lost or damaged materials are payable to the lending library, and are to be forwarded by the library to which payment is made.

(f) Special loan privileges extended by the participating public library to teachers and other groups within its jurisdiction need not be extended beyond the jurisdiction.


ยง20205: An eligible non-resident borrower must be a resident of California,

(a) Hold a valid borrowers card issued by their home library, or

(b) Hold or obtain a valid non-resident borrowers card issued by any California public library, or

(c) Hold a valid state borrowers identification card issued by any California public library;

(d) And present any additional identification normally required by a library of its own residents.

(e) Nothing in this section shall prevent the issuing of a non-resident card or charging of fees to a resident of another state, except that loans to such non-residents shall not be counted as reimbursable transactions.


I strongly urge that you write to your State Senator, State Representative and the Governor of Oregon to express your support to pass legislation to give Oregonians a Universal Borrowing Privilege.  Here's a link where you can find their email addresses:

https://www.oregonlegislature.gov/FindYourLegislator/leg-districts.html

Saturday, April 18, 2020

Death rates

In the news, we are told that Covid-19 has killed 37,841 people as of 4/18/2020.  While the rate has varied, it seems to be about 2100-2200 people per day.  So let's get some context around that.
The population of the US is approximately 330 million people.  The average life expectancy is 78.5 years.  This means that each year, 4.2 million people die.  That is 11,517 people per day.  So what we are saying seems to be that an extra 20% of death is being handed out?  Not necessarily.  Later, government statistics will come out to determine whether Covid-19 was killing people in addition to normal causes of death, or rather instead of normal causes of death.
Repeating the calculation for Oregon, with the same life expectancy and a population of 4.2 million, normally 147 people die each day.  Currently, the number of deaths from Covid-19 seems to be about 4 or 5 people per day.  This is a much lower rate in comparison to the national picture.  Here one might argue that it is much more likely that people are being killed by Covid-19 rather than some other causes such as traffic and gun accidents because of social distancing measures.  In other words, probably Covid-19 is not adding to the death toll, people are dying at the same rate as before but for different reasons.  Unfortunately, data compilation, validation and publishing take time, so resources such as CDC's Wonder are not going to answer just what kind of effect Covid-19 has had on the country until later.
Just also want to note that I have way simplified the subject.  There are regional and seasonal variations.  The short term effect of social distancing may be very hard to determine vs. the effect of the Covid-19 infection rate.  Assumptions of paribus ceteris may be invalid for many reasons.  Also, it is not clear that we have reached the peak of the mortality curve for the US or the deaths from Covid-19 could possibly remain level for some weeks.  In the case of a doubling of the daily death rate or a sustained high level, then clearly the virus is adding marginally to the death rate and the life expectancy will go down when they calculate the statistics.  For example, if we assume that 2200 daily deaths are indeed on top of the normal national death rate, then this would reduce the life expectancy to 65.9 years which is a pretty significant reduction.
Again, I want to stress that we won't be able to figure out the actual effects until all the data has been gathered and analyzed but it sure is fun to speculate about it.

Saturday, April 11, 2020

Random Alien Writing

I've been thinking about this for some time and finally found some time to write the program.  The program is at the bottom of the post and written with Python 3.8.  Basically, it creates a canvas filled with strange looking writing.  I was inspired by some of the examples of "alien" writing used in various sci-fi movies and TV shows.  I thought to myself, should be easy to create a program that can create examples of this kind of writing.  I re-used the basic framework I had developed for the program to simulate cellular automata. (I have re-used the framework for some other bits I've made for myself, not (yet) posted here and it is becoming one of my favorites.)  My first attempts, frankly, looked like white noise on a screen.  Over a couple of days I refined the parameters to get it closer to what the brain will recognize as having some semantic content and organization and the current version is pretty good.  I've used it to generate the background I've added to the blog.  I hope you like it!  I'm not going to go into a detailed explanation of the program elements, but if you have questions about it, post a comment.

The Program




from tkinter import *
from random import randint

class App:
    """This class is derived, I think, from a TK class and is designed to
    work with the TK environment.
    Requires imports from Tkinter, math, and random"""
    def __init__(self, master):
        """This class is the whole of the application """
        # Necessary Frames
        frame = Frame(master)
        control_frame = Frame(frame)
        control_frame.grid(row = 0, column = 0, sticky = N)
        canvas_frame = Frame(frame)
        canvas_frame.grid(row =0, column = 1)

        #Application variables
        self.char_pts = [(1,1),(7,1),(14,1),(1,7),(7,7),(14,7),(1,14),(7,14)
                         ,(14,14)]
        self.chars = []
        self.text = []
        self.tmpstr = '\nFor another,\nHit Randomize'
        
        #Control FrameWidgets
        self.lab = Label(control_frame, text=self.tmpstr)
        self.lab.pack(side = TOP)
        self.b1 = Button(control_frame, text='Randomize')
        self.b1.config(command=self.randomize)
        self.b1.pack()
        
        # The Canvas
        self.canvas = Canvas(canvas_frame, width = 800, height = 800)
        self.canvas.config(bg='white')
        self.canvas.pack()
        frame.pack()

        #Menu
        menubar = Menu(root)
        menu_1 = Menu(menubar, tearoff=0)
        menu_1.add_command(label='Quit',command=root.destroy)
        menubar.add_cascade(label='File', menu=menu_1)
        master.config(menu=menubar)
        self.randomize()

    def randomize(self):
        self.canvas.delete(ALL)
        # create characters
        self.chars = []
        for j in range(10):
            new_char = []
            b = randint(0,8)
            for i in range(randint(2,7)):
                a = b
                b = (a + randint(1,8))%9
                new_char.append((a,b,randint(1,2)))
            self.chars.append(new_char)
        # create text, in 2-7 letter long words.
        tl = 0
        self.text = []
        while tl <3000:
            wl = randint(2,7)
            for k in range(wl):
                self.text.append(randint(1,len(self.chars)-1))
            tl = tl + wl + 1
            self.text.append(0)
        # now write the text using the characters
        i = 0
        j = 0
        for char in self.text:
            if char != 0:
                for seg in self.chars[char]:
                    start = seg[0]
                    end = seg[1]
                    wt = seg[2]
                    x1 = i*15+self.char_pts[start][0]
                    y1 = j*17+self.char_pts[start][1]
                    x2 = i*15+self.char_pts[end][0]
                    y2 = j*17+self.char_pts[end][1]
                    if x1==x2 or y1==y2:
                        self.canvas.create_line(x1,y1,x2,y2,width=wt)
                    else:
                        self.canvas.create_arc(x1,y1,x2,y1,width=wt)
            if i == 50:
                j = j + 1
                i =0
            else:
                i= i + 1
        self.canvas.update()

if __name__ == '__main__':
    root = Tk()
    root.wm_title('Alien Text')
    app = App(root)
    root.mainloop()
     


Thursday, April 9, 2020

About "random" numbers

It is an interesting thing that if you were to ask some person to give you a "random" 6-digit number, they would tend to try really hard to not repeat digits.  People have a tendency to think that random number do not have repeating digits.  But an analysis of these numbers shows that, in fact, for longer numbers, it starts to be more likely that there are repeated digits than not.  Below is a table of the number of digits and the likelihood that there are repeating digits.
(argh, excuse me but there is not a control to create a table!!)
Number of digits vs. likelihood of repeated digits:

  1. None
  2. 9.99%
  3. 28%
  4. 50%
  5. 70%
  6. 85%
  7. 94%
  8. 98%
  9. 99%
  10. nearly 100%
So the psychology going on here is that people have a sense in 2 digit and maybe 3 digit numbers that repeated digits in a number are rarer than unique.  However, in reality, when you get to 5 and 6 digit numbers, most numbers have repeated digits.
The math of permutations and combinations is explained here .
The python math module functions are explained here.  The ones that are relevant are the factorial, comb and perm functions.  I wrote some code to re-create these.  I found out that after 10 levels of recursion, Python gives you an error message.  So I had to use the math module version of the factorial function.

# This defines the permutation function
# and the combination function

from math import factorial

def perm(n,r):
    return factorial(n)/factorial(n-r)

def comb(n,r):
    return factorial(n)/factorial(n-r)/factorial(r)

for i in range(2,11):
    print(i,1-perm(10,i)/10**i)

Also, if you don't believe the math, I also wrote a piece of code that does a brute force calculation.  It does take some time to work its way through all the different combinations.  And it will not give the exact same results since it is not considering the numbers that start with 0.
 
# This program prints out how many of the numbers in a range
# have repeating digits

n = 2
flag = True
while flag:
    test = 10**(n-1)
    count = 0
    print(test)
    while test < 10**n:
        a = str(test)
        dupe = False
        for i in range(10):
            if a.count(str(i))>1:
                dupe = True
        if dupe:
            count = count + 1
        test = test +1
    ratio = count / 10**n
    print(n,count, ratio)
    ask = input("continue? (n to end) >")
    if ask == 'n':
        flag = False
    n = n+1
So it's an interesting bit of psychology so I hope you enjoy it.