Jul 7
Ubuntu on Toshiba AC100
icon1 Mikkel Meyer Andersen | icon4 July 7, 2011 at 13:47 (UTC) | icon3 No Comments »
icon3

I have recently bought a Toshiba AC100-10D (it was quite cheap because it's now old, but the hardware is still quite similar to that of the new tablets). I bought it with the expections of installing Ubuntu on it (I don't really need Android - I have an Android phone which is good for that purpose, but I'd like Latex, R etc. available on a netbook).

I found some tutorials on how to install Ubuntu, but I didn't really have any success until I found http://salaliitto.com/~gildean/ac100/wiki/phh/ . So thanks a lot to gildean! I would recommend that you follow that guide if you want to install Ubuntu to your Toshiba AC100. At least until Ubuntu 11.* supports the machine better, see e.g. https://launchpad.net/~ac100/+archive/ppa .

Feb 24
Java: Power set and set partitioning using bitwise operations
icon1 Mikkel Meyer Andersen | icon4 February 24, 2011 at 18:32 (UTC) | icon3 No Comments »
icon3 ,

To tasks are quite common, especially writing math programs:

These two operations are of course interesting for Set<T> and cousins, but from a mathematical point of view, it is sufficient to solve this for index sets, i.e. sets {0, 1, ..., n - 1}. For List<T> and cousins (allowing duplicates), it can be a slightly different story depending on your view on the duplicates. So the rest of this post deals with index sets of size n, i.e. {0, 1, ..., n - 1}.

Especially for power sets, numerous implementations use strings. That I do not fancy. I tried to find implementations not using strings but merely used bitwise operations (which is also what the string using implementation does but they bring strings into the picture, maybe because it makes the programming a bit easier).

If you use some of this code in commercial software, you have to contact me first and make an agreement of usage. If your use is not commercial, feel free to use the code as long as you don't take credit for it yourself.

My implementations of the operations is shown below. Please contact me for questions or comments.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/**
 * Get the power set of {0, 1, ..., n}.
 * 
 * @param n the upper bound in the index set {0, 1, ..., n} to get the power set of
 * @return the powerset including the empty set and the set itself as the first and last element, respectively
 * @author Mikkel Meyer Andersen, scienco [at] mikl [dot] dk
 */
public static int[][] getPowerset(int n) {
    if (n <= 0) {
        throw new IllegalArgumentException("n must be be at least 1");
    }
 
    // stop at (2^n) - 1, so calculate 2^n
    final int stop = 1 << n;
 
    int i0 = 0, i1;
    int[][] powerset = new int[stop][];
 
    // Starting at i = 0 gives an empty first pair, so start at i = 1
    for (int i = 0; i < stop; ++i) {
        int j = i;
        int k = i;
 
        int size = 0;
 
        // First calculate size of the array needed
        for (int r = n - 1; r >= 0; --r) {
            if ((j & 1) == 1) {
                size++;
            }
 
            j >>>= 1;
        }
 
        i1 = 0;
        int[] set = new int[size];
 
        for (int r = n - 1; r >= 0; --r) {
            if ((k & 1) == 1) {
                set[i1++] = r;
            }
 
            k >>>= 1;
        }
 
        powerset[i0++] = set;
    }
 
    return powerset;
}
 
/**
 * Partition an index set {0, 1, ..., n} into two parts A and B such that A
 * union B is the whole set and A and B are disjoint. If you use this in
 * commercial software, do contact me first. If not, feel free to use this
 * code as long as you don't take credit for it yourself.
 * 
 * @param n the upper bound in the index set {0, 1, ..., n} to get pairs of
 * @return the pairs
 * @author Mikkel Meyer Andersen, scienco [at] mikl [dot] dk
 */
public static int[][][] getPairs(int n) {
    if (n <= 1) {
        throw new IllegalArgumentException(
                                           "n must be be at least 2 (it takes at least two elements to create a pair)");
    }
 
    // stop at 2^(n-1) - 1, so calculate 2^(n-1)
    final int stop = 1 << (n - 1);
 
    int i0 = 0, i1, i2;
    int[][][] pairs = new int[stop - 1][][];
 
    // Starting at i = 0 gives an empty first pair, so start at i = 1
    for (int i = 1; i < stop; ++i) {
        int j = i;
        int k = i;
 
        int size = 0;
 
        // First calculate size of the array needed
        for (int r = n - 1; r >= 0; --r) {
            if ((j & 1) == 1) {
                size++;
            }
 
            j >>>= 1;
        }
 
        i1 = 0;
        i2 = 0;
        int[] set1 = new int[size];
        int[] set2 = new int[n - size];
 
        for (int r = n - 1; r >= 0; --r) {
            if ((k & 1) == 1) {
                set1[i1++] = r;
            } else {
                set2[i2++] = r;
            }
 
            k >>>= 1;
        }
 
        pairs[i0++] = new int[][] {
            set1, set2
        };
    }
 
    return pairs;
}
 
/**
 * Formats the power set of {0, 1, ..., n} obtained by {@link getPowerset}
 * in a nicely looking string.
 * 
 * @param powerset the powerset to format nicely
 * @author Mikkel Meyer Andersen, scienco [at] mikl [dot] dk
 */
public static String powersetToString(int[][] powerset) {
    StringBuilder sb = new StringBuilder();
 
    for (int i = 0; i < powerset.length; ++i) {
        int[] set = powerset[i];
 
        for (int j = 0; j < set.length; ++j) {
            sb.append(set[j]);
 
            if (j < set.length - 1) {
                sb.append(", ");
            }
        }
 
        if (i < powerset.length - 1) {
            sb.append("\n");
        }
    }
 
    return sb.toString();
}
 
/**
 * Formats the different pairs partitioning the index set of {0, 1, ..., n}
 * obtained by {@link getPairs} in a nicely looking string.
 * 
 * @param pairs the pairs to format nicely
 * @author Mikkel Meyer Andersen, scienco [at] mikl [dot] dk
 */
public static String pairsToString(int[][][] pairs) {
    StringBuilder sb = new StringBuilder();
 
    for (int i = 0; i < pairs.length; ++i) {
        int[] set1 = pairs[i][0];
        int[] set2 = pairs[i][1];
 
        sb.append("(");
 
        for (int j = 0; j < set1.length; ++j) {
            sb.append(set1[j]);
 
            if (j < set1.length - 1) {
                sb.append(", ");
            }
        }
 
        sb.append("), (");
 
        for (int j = 0; j < set2.length; ++j) {
            sb.append(set2[j]);
 
            if (j < set2.length - 1) {
                sb.append(", ");
            }
        }
 
        sb.append(")");
 
        if (i < pairs.length - 1) {
            sb.append("\n");
        }
    }
 
    return sb.toString();
}

The usage is exemplified with the following example:

int[][][] pairs = Utils.getPairs(4);
System.out.println(Utils.pairsToString(pairs));
 
int[][] powerset = Utils.getPowerset(4);
System.out.println(Utils.powersetToString(powerset));

The output is:

(3), (2, 1, 0)
(2), (3, 1, 0)
(3, 2), (1, 0)
(1), (3, 2, 0)
(3, 1), (2, 0)
(2, 1), (3, 0)
(3, 2, 1), (0)
 
3
2
3, 2
1
3, 1
2, 1
3, 2, 1
0
3, 0
2, 0
3, 2, 0
1, 0
3, 1, 0
2, 1, 0
3, 2, 1, 0
Sep 30
(Ugly) custom case for Amazon Kindle 3rd generation
icon1 Mikkel Meyer Andersen | icon4 September 30, 2010 at 12:20 (UTC) | icon3 No Comments »
icon3

At couple of days ago I got my Amazon Kindle ($139, 3rd gen.). So far I'm really happy with it! While buying it, I decided that the cases were too expensive compared to the device. So I decided to make one myself. And as suspected, there was no happy end in that story. So hopefully the Amazon guys will read this post and view the pictures. And pity me. But the device itself is awesome and I enjoy using it. Only a couple of objections:

  • Come on: use an open e-book format
  • Support a library loan function (I know it's against your business as such, but it would be nice)

And the pictures:

Sep 15
STA: Statistical Toolbox for Android now in version 0.4
icon1 Mikkel Meyer Andersen | icon4 September 15, 2010 at 20:52 (UTC) | icon3 No Comments »
icon3 , ,

STA: Statistical Toolbox for Android has recently been updated to version 0.4. Among news compared to version 0.3 is the support for performing one way ANOVA and two kinds of Student's t-test. View a full changelog here.

To present the application, it offers three main areas:

  • Distribution tool
  • Statistical tests
  • Descriptives

Distribution tool

The distribution tool offers the following features: plot the pdf/pmf, properties (like mean value, variance, and support), cumulative probability, point mass/density, quantiles, and generating/sampling from the distribution. The probability distributions supported are:

Discrete probability distributions:

  • Binomial
  • Hypergeometric
  • Negative binomial (or Pascal as it is also called)
  • Poisson
  • Zipf

Continuous probability distributions:

  • Beta
  • Cauchy
  • Chi^2 (Chi squarred)
  • Exponential
  • F (or Fisher-Snedecor as it is also called)
  • Gamma
  • Normal (or Gaussian as it is also called)
  • Student's t
  • Weibull

Statistical tests

At the moment, the following tests are supported:

  • One way ANOVA (i.e. univariate)
  • Chi^2 tests: Pearson's Chi^2 test for independence and observed vs expected counts
  • Two sample Student's t-tests: both homoscedastic and heteroscedastic are supported

Descriptives

The following descriptive statistics about an entered dataset are given:

  • Number of observations
  • Min
  • Max
  • Mean
  • Standard deviation
  • Variance
  • Median
  • Skewness
  • Kurtosis

Comments

Please do not hesitate to express you thought about the application. Also, ideas for further functionality are warmly welcome! And donations to support the continuous development are highly appreciated (donations can be made by using the box in the upper right corner of this page)!

Aug 5

Dear users,

It is with sadness that I have to inform you that Watexy will be discontinued. This is a direct consequence of Google pulling the plug on Google Wave (see e.g. http://digihub.theage.com.au/node/1792).

Watexy (and associated web-service) gets deleted on 31st of August 2010.

I'm very sorry, but hosting the bot is quite expensive, so I don't see much point in making the deficit any bigger when Google Wave is going to close anyway. And I have to remind you that Google Wave has always been a beta, so the risk of this happening has been present all the time.

Deleting Watexy and associated web-service means that all your waves with Latex-images/-equations will be useless; the images will not appear any longer. This means that you either have to print the waves before 31st of August 2010 or use the history functionality to get back to the Latex-codes.

I am very sorry for this but I see no other opion.

Jul 14
STA version 0.2
icon1 Mikkel Meyer Andersen | icon4 July 14, 2010 at 19:06 (UTC) | icon3 No Comments »
icon3 , ,

Already an update with the following changes from version 0.1:

General:

  • Icon changed
  • Decimal separator always "." no matter the chosen locale of the phone (for consistency purposes)
  • Screen rotate issues fixed

Distribution tool:

  • Typing error: Continuous distributions density output changed from "F([input]) = ..." to "f([input]) = ..."
  • Error description at the parameter tab if the parameters are illegal when trying to plot
  • Descriptives gets calculated automatically when sampling data
  • The link under properties has been made clickable
Jul 13
STA (Statistical Toolbox for Android) version 0.1
icon1 Mikkel Meyer Andersen | icon4 July 13, 2010 at 10:50 (UTC) | icon3 No Comments »
icon3 , ,

Finally, a ("beta") version 0.1 of STA is available on the market. Just search for STA. Please let me know if you run into trouble or would like certain features!

Jul 6
STA: Statistical Toolbox for Android
icon1 Mikkel Meyer Andersen | icon4 July 6, 2010 at 13:32 (UTC) | icon3 3 Comments »
icon3 , ,

After having done some preliminary application development for Android (and finally finished my master's), I've decided to start a new project. And to blog about the creation of this new project. (As an aside I would really like to point out that I haven't forgot about Watexy, but for now it is not possible to improve it.)

The aim of the project is to develop an Android-application with basic statistical tools (I really miss R on my phone, but the project won't be a R-clone nevertheless). So far the codename for the application is Statistical Toolbox for Android (or simply STA).

It is not going to be a programming language such as S, but an easy-to-use graphical statistical toolbox. The features I've thought about including in the first version are:

  • Quantiles (and fractiles) for a wide range of univariate probability distributions
  • Descriptive statistics (the first two or three empirical moments, correlation measures)
  • A guide for choosing the right statistical test

The features for the later versions could be:

  • Loading datasets (from mail, files on SD-card, or manual input)
  • A range of statistical tests

If any of you have any comments, please do not hesitate to submit a comment here or by mail (use the contact form accessible from the top menu or by sending an e-mail to the reverse of mikl.dk @ scienco ).

Feb 25

I've been working on a robot just like Watexy, but instead of converting Latex to images, it should convert to MathML-fonts. And I'm actually quite far with the robot, so I assume that something will be ready within a couple of days (or maybe a week). Stay tuned!

Oh - and I removed the ads on the site. They was indeed annoying! I hope that you will help the development and server expenses by donating a bit if you can afford it. And thanks to those who already donated - it's much appreciated!

Nov 14
Watexy version 14 – with both inline and display math mode
icon1 Mikkel Meyer Andersen | icon4 November 14, 2009 at 23:15 (UTC) | icon3 35 Comments »
icon3 , , , ,

Now version 14 of watexy@appspot.com is released.

$ $x$ $ makes an inline equation (with the $-signs immediately following each other and not with a space as here).

 4 + 5

makes an equation in "display math mode", i.e. centred on its own line. Edit by clicking at the equation (the image).

There are still a few misbehaviours/new feature suggestions:

  • Inline equations still doesn't support < and >
  • It's still not possible to edit the inline equations
  • Have an align environment so that several equations can be shown underneath each other
  • The height of the equation in display math mode doesn't always adjust automatically, so it may be necessary to either click it to edit and the press cancel or view another wave and go back to the original one
  • The history of how an equations is changed (editing by clicking on it) is not recorded, so for know it's not possible to track changes to a single equations. Yet.

I'm of course still working to fix these things, but it might not be solved until January because I'm going to travel the rest of the year.

Thanks a lot for your support and all the feedback. Please continue to comment on how the robot is made, bugs, and suggestions! I'm also on Twitter at http://twitter.com/mikldk.

A last request: If you can afford, please donate money to support my work and expenses. You'll find the donate-button in the upper right corner of this page.

« Previous Entries