Friday, December 25, 2009

JEE 6 has been approved!

See the ballot here: http://jcp.org/en/jsr/results?id=5025

ASF voted against the proposal. The comment ASF gave is:

"The Apache Software Foundation's vote is based on the point of view that this spec lead - Sun - is in violation of the JSPA

http://www.apache.org/jcp/sunopenletter.html

and therefore shouldn't be allowed to lead other JSRs until the above matter is resolved.

This vote is not a comment on the technical merits of the JSR.  If not for the issue of the spec lead, the ASF would have otherwise voted "yes".

I read http://www.apache.org/jcp/sunopenletter.html. It seems the dispute originates from license of JCK (Java Compatibility Kit) which is needed to demonstrate compatibility of Java SE spec. Also IBM voted for the proposal but stated that it wants an open licensing model, etc. Interesting relationships among those vendors and foundations.

The problem has been there for several years, and it still has not been solved.

Thursday, December 24, 2009

A ball probability question

I was looking for a solution to a ball probability question which is described below. I found this page which exactly describes the same question: http://www.isibang.ac.in/~statmath/problems/august.html. However, it seems the page is not accessible now. So I copied the page and pasted it here. If this incurs any term/license problem, I am more than glad to remove the content.

Suppose Farrah gives you two bags. Bag A, contains 50 Red balls and Bag B, contains 50 Black Balls. She leaves the room asking you to rearrange the balls between the bags in any way you want without discarding any of the balls. She then returns and chooses a bag at random and then from the chosen bag, chooses a ball at random.

Question: Can you find the rearrangement that maximises her chance of choosing a black ball ?



Solution provided by Winners :

  • Soumya bhattacharya
    Clearly,if one bag contains only black balls and the other bag atleast one black ball along with the red balls,then the prabability that Farrah choses a black ball is more than half.

    Again if any of the bags contain equal no. of black and red balls ,then the other bag also contains them in equal number and (if none of them is an empty bag,in which case the probability of Farrah's chosing a black ball is only 1/4) the probability that Farrah choses a black ball is half.As we already have seen an example in which the probability of chosing a black ball is more than half,hence this case can't be the solution.

    So,if an optimal case exist,in that each of the bags must contain unequal numbers of black and red balls.And hence,(as the total no. of black balls= the total no. of the red balls) the proportion of black balls in a bag will be more than half in one bag and less than half,in the other. let 'b' and 'd' denote the total no. of balls in 2 bags and 'a' and 'c' denote the total no. of black balls in them respectively.

    W.L.O.G.,let us assume that a/b < 1/2 and c/d > 1/2.Now if we take out a black and a red ball from the 2nd bag and put them in the first,the probability of chosing a black ball changes from (1/2)*(a/b + c/d) to (1/2)*((a+1)/(b+2) + (c-1)/ (d-2)). Again as a/b < 1/2,hence we have (a+1)/(b+2) > a/b. And as c/d > 1/2, (c-1)/(d-2) > c/d.

    Therefore, by this rearrangement,the probability of chosing a black ball increases.So we do it untill there is no red ball in the bag,which was initially containing d balls.( as there were more black balls initially in this,and we shift equal no. of red and black balls to the other bag.) Now, clearly if we shift all the black balls,leaving only one in the first bag to the bag that contains red balls also,then the ratio of blacks to reds increases in the 2nd bag ,whereas that in the 1st bag remains constant, in effect increasing the probability of chosing a black ball by Farrah.

    So,starting with any arbitrary case we have reached the state of rearrangement, which has the probability of chosing a black ball more than or equal to that arbitrary case.So, we conclude that ,the rearrangement of the balls in which one bag contains only 1 black ball and the other bag contains the rest of the balls is maximum (0.7474).

  • Subhroshekhar Ghosh

    First of all, we claim that the required arrangement is : one black ball in one of the jars and all the other balls in the other jar, when the probability p of getting a black ball turns out to be 1/2*1 + 1/2 * 49/99.

    To, see this, we eliminate the cases 1.all the balls are in one jar (p=1/4) 2.there are equal no. of red and black balls in one jar (and hence in the other jar) (p=1/2).

    We observe that for any labelling of the jars as 1 and 2, p=1/2*p(1)+1/2*p(2) where p(i) is the conditional probability of getting a black ball having chosen the ith jar. Also, as there are equal no. of red and black balls, in any configuration there will be exactly one jar in which no. of red balls >= no. of black balls, hence the conditional probability for that jar <= 1/2. Since we have eliminated cases 1 and 2, we will have it < 1/2.

    Without loss of generality, we call this jar 1 and let it have r red and b black balls. Then p(1)=b/(r+b), b0. We have p(1)<1/2, so we consider 1/2 - p(1) = 1/2 * {(r-b)/(r+b)}. The restrictions imply (r-b)>= 1 and r+b <=99. Therefore, 1/2 - p(1) >= 1/2 * 1/99, so p(1) <= 49/99, equality holds if there are 50 red and 49 black balls in jar 1. The other conditional probability p(2) <= 1, equality holds if all balls in jar 2 are black. Hence, p will be maximised if both of these upper bounds are attained. But they are attained by the configuration mentioned in the beginning. In fact, it is clear from the equality conditions that this configuration is the only one that attains the upper bound.

  • Tuesday, December 22, 2009

    Interesting “Epigrams on Programming”

    Recently I found this

    Epigrams on Programming: http://www.pam1.bcs.uwa.edu.au/~michaelw/Perlis_Epigrams.html

    Really interesting, terse and helpful. Among those epigrams, I like following ones a lot

    1. Programming is an unnatural act.
    2. Computer Science is embarrassed by the computer.
    3. In man-machine symbiosis, it is man who must adjust: The machines can't.

    Saturday, November 07, 2009

    Simplest RFC?

    Which is the simplest RFC? Maybe this one: http://tools.ietf.org/html/rfc863

    DISCARD: the server just discards all received messages.

    Friday, November 06, 2009

    Windows7 7 Sins

    An interesting web site: http://en.windows7sins.org

    Saturday, September 26, 2009

    Classloaders, shared directory and endorsed directory of Tomcat 5.5 and 6.0

    Tomcat 5.5 Class Loader: http://tomcat.apache.org/tomcat-5.5-doc/class-loader-howto.html
    Tomcat 6.0 Class Loader: http://tomcat.apache.org/tomcat-6.0-doc/class-loader-howto.html

    Tomcat 5.5

    Class loader hierarchy
    image  (from tomcat 5.5 document)

    Class loaders:

    • Boostrap, System
    • Common:
      visible to both Tomcat internal classes and to all web applications.
      Related directories
      • classes and resources in: $CATALINA_HOME/common/classes
      • jar files in: $CATALINA_HOME/commons/endorsed, $CATALINA_HOME/commons/i18n and $CATALINA_HOME/common/lib
    • Catalina
      include all classes and resources required to implement Tomcat 5 itself. These classes and resources are TOTALLY invisible to web applications.
      Related directories:
      • classes and resources in: $CATALINA_HOME/server/classes
      • jars in: $CATALINA_HOME/server/lib
    • Shared
      Shared resources are shared across all web applications. (They are not used by Tomcat internal classes).
      Related directories
      • classes and resources in: $CATALINA_BASE/shared/classes
      • jars in: $CATALINA_BASE/shared/lib
    • WebappX
      Load web app specific resources and jars.
      Related directories
      • classes and resources: <web-app-dir>/WEB-INF/classes
      • jars: <web-app-dir>/WEB-INF/lib

    Note: $CATALINA_BASE (not $CATALINA_HOME) is used class loader “Shared”.

    #   CATALINA_HOME   May point at your Catalina "build" directory.
    #
    #   CATALINA_BASE   (Optional) Base directory for resolving dynamic portions
    #                   of a Catalina installation.  If not present, resolves to
    #                   the same directory that CATALINA_HOME points to.

    Tomcat 6.0

    Class loader hierarchy
    image   (from tomcat 6.6 document)
    Similar to the hierarchy in tomcat 5.5. 
    The difference is that class loaders Catalina and Shared are not present in tomcat 6.6.
    For Class loader Common, the related directories are different. In tomcat 6, classes, resources and jars under directory $CATALINA_HOME/lib (in tomcat 5.5, the directory is $CATALINA_HOME/common/classes, $CATALINA_HOME/common/lib, etc) are loaded by class loader Common.

    These directories under which classes and resources are searched for can be changed by modifying configuration file $CATALINA_HOME/conf/catalina.properties.
    Default values for class loader search directories are:

    common.loader=${catalina.home}/lib,${catalina.home}/lib/*.jar
    server.loader=
    :shared.loader=

    If you still want to use shared directory in the way specified in tomcat 5.5, you can change value of property shared.loader.
    For example: shared.loader=${catalina.base}/shared/classes,${catalina.base}/shared/lib/*.jar

    Endorsed directory

    Tomcat 5.5

    “Tomcat utilizes this mechanism by including the system property setting
    -Djava.endorsed.dirs=$CATALINA_HOME/common/endorsed in the command line that starts the container. Therefore, you can replace the parser that is installed in this directory, and it will get used even on a JDK 1.4 system.”

    Tomcat 6.0

    Tomcat utilizes this mechanism by including the system property setting
    -Djava.endorsed.dirs=$JAVA_ENDORSED_DIRS in the command line that starts the container.

    Variable JAVA_ENDORSED_DIRS is specified in file setclasspath.sh: 
        JAVA_ENDORSED_DIRS="$BASEDIR"/endorsed

    Variable BASEDIR is specified in file catalina.sh:
        BASEDIR="$CATALINA_HOME"

    In other words,
        in tomcat 5.5, the default endorsed directory is $CATALINA_HOME/common/endorsed
        in tomcat 6.0, the default endorsed directory is $CATALINA_HOME/endorsed

    Thursday, September 24, 2009

    Apache ten years

    Some really nice articles/interviews about Apache Software Foundation:
    http://dev.day.com/microsling/content/blogs/main/apachebirthday.html
    ASF highlights: 1999-2009 http://www.apache.org/press/highlights.html
    Details about how ASF works: http://www.apache.org/foundation/how-it-works.html
    eWeek: 11 Apache Technologies that Have Changed Computing in the Last 10 Years
    http://www.eweek.com/c/a/Application-Development/11-Apache-Technologies-that-Have-Changed-Computing-in-the-Last-10-Years-469693/

    Saturday, September 12, 2009

    SVN: exclude some files out of version control (using svn:ignore)

    Sometimes, you don’t want SVN to include all you files in the source code directory because they may be temporary files generated by developers or tools (vimcreates .swp file when a file is opened in vim).
    SVN book: http://svnbook.red-bean.com/en/1.5/svn.advanced.props.special.ignore.html

    Two ways

    o   Global change: it is applied to all svn operations performed using the runtime configuration. In other words, it changes the configuration of svn application (not a specific directory/file under control of svn)

    o   Bind configuration to a specific version tree using svn:ignore property.

    o   The ignore pattern checking is applied only during adding of unversioned directories/files to svn control.
    Once an object is under Subversion's control, the ignore pattern mechanisms no longer apply to it. In other words, don't expect Subversion to avoid committing changes you've made to a versioned file”

    o   Its value contains a list of NEWLINE-delimited file pattern

    o   They don’t override global global-ignores configuration, but append to the list

    o   “the patterns found in the svn:ignore  property apply only to the directory on which that property is set, and not to any of its subdirectories.”
    Use switch –R if you want to apply it recursively.

    o   Usage
    svn propset svn:ignore -F file-contains-ignore-patterns path-ignore-to-be-applied
    Examples:
        svn propset svn:ignore -F .svn-ignore .
        #recursive. If you change the direcotry tree after this command is run,
        #you need to return following command to make the newly created directories/files controlled also by ignore pattern.
        svn -R propset svn:ignore -F .svn-ignore .   
        # edit a property

        svn propedit svn:ignore .     #edit the ignore patterns using the preconfigured editor.
    Note:
      *)  If you use a file to specify ignore patterns, you must rerun the command
                  "svn propset svn:ignore -F your-patter-file ."
        to make svn reread the file after the pattern file is changed.
      *)  One alternative is to use
                  "svn propedit svn:ignore ."
           to edit the property configuration. Then the change you made immediately takes effect. However, the new property value will not be written back to the original pattern file. You can use command
        "svn propget svn:ignore . >  pattern-file"
    to export the new value to your pattern file.

    o   File Pattern
    *: match any sequence of characters
    ?: match single character
    [char-set]: match the specified char set.

    o   Command “svn add”
    When you use wildcards, you should be careful because it may make svn bypass the ignores check.
    See http://svnbook.red-bean.com/trac/ticket/115.
    Basically, “svn add * bypasses the ignores system. However, it has been fixed. So if you are using a latest svn version, it should not be a problem.
    Anyway, use “svn add --force . when you can (it makes svn check the whole specified directory tree).

    o   Command “svn status” won’t list ignored directories/files.
    Use “svn status --no-ignore” to list status of all files including ignored ones.

    Tuesday, September 08, 2009

    test

    Hello, worl

    Thursday, August 20, 2009

    test post from linux using blogtk 1.1