Jasp developing team
(The Institute of Statistical Mathematics)
YAMAMOTO Yoshikazu
(Tokushima Bunri University)
(Tokushima Bunri University)
(Tokyo University of Information Science)
HONDA Keisuke
(Open Technologies Corporation)

| TOP |
Jasp language
Design of language
In statistical packages, language or macro for describing statistical procedures is important especially for advanced or frequent users. Statistical language should be simple and intuitive for tentative programming work, appropriate to write large and complex programs and able to reuse existing codes repeatedly and smoothly.

It is known that simplicity and flexibility of programming for statistical analysis can be achieved by functional language interpreters like S or XploRe. It is also admitted that object oriented languages are useful to write reusable and rigid programs for large systems. For example, C++ is mainly used for building complex systems. Considering these facts, We decide to design new functional and object oriented language for statistics, which is as simple as possible but enough suitable to modern computational environments.

We use Java language for building our statistical system, because it adopts many modern advanced features of computer science in it. Java language is well designed and easier to use than C++ language, and a pure object oriented compiler language. We think, however, it is still difficult for statisticians, who are not professional programmers, to use it as a daily tool for statistical analysis.

We decide to use Pnuts as the basis of Jasp language, because Pnuts is much simpler than Java and still can enjoy the merits of Java. Pnuts is a script language interpreter written in Java and has simple functional syntax and built-in language extension facility. Pnuts can use Java classes directly and seamlessly.

As Pnuts is a general purpose language and lacks desirable functions for statistical work, we add such facilities to Pnuts, and name it Jasp language. As Pnuts can use Java classes easily, we use Java classes freely available for basic statistical work: Jampack (Stewart, 2000) for calculating matrices, Ptplot (Lee and Hylands, 2000) for drawing graphics, and Colt (Hoschek, 2000) for computing probability distributions and generating random numbers. We make Jasp interpreter by adding some programs on Pnuts to use these classes effectively. Jasp language is basically a functional language as Pnuts is. Jasp function has no type declaration and easy to use without any care for variable types. A simple example of Jasp function is:

  • function ols(y,x){
    • coeff = (x.trans * x).inv * x.trans * y
    • return coeff
  • }

We can write all statistical procedures by defining Jasp functions.

When we write a lot of functions for our particular analysis, we often notice that they should be bundled in some way for reusing them in future work. We also know that some functions are related to a particular kind of data set. These characteristics are expressed by object oriented approach so well that we add this structure to Jasp language as one of the basic properties. We recommend to use this mechanism to define classes for assembling closely related functions and variables. In Jasp language, Java classes and Jasp classes are used almost similarly. This means that we can extend Jasp by both Jasp and Java languages. Basic system extensions should be realized by Java classes, and advanced statistical classes, for example, linear regression analysis or principle component analysis, should be written in Jasp language. An example of Jasp class definition is:

  • jaspclass LinearRegression {
    • method LinearRegression(y,x){
      • this.beta = ols(y,x)
      • this.forecast = x * beta
    • }
    • function ols(y,x){
      • coeff = (x.trans * x).inv * x.trans * y
      • return coeff
    • }
  • }

Note that above defined function is used without any modification in this class definition, and can not be called from outside of the object. Variables prefixed by "this." and all methods are accessible anywhere. The method whose name is same as the class name is a constructor of the class. All Jasp functions also can be thought as constructors. In a class definition, a class can inherit another class like other object oriented languages.

Foreign language interface
Although many good statistical systems are available, not a few statisticians still write their programs for statistical research in traditional languages, because they have used such languages for a long time and/or need huge amount of calculation by high performance computers on which modern statistical systems do not work. Their programs implement advanced statistical techniques developed by themselves but are usually difficult to use because of the lack of good UI. To merge their programs into general purpose statistical systems is an important task. Therefore, foreign language interface is also indispensable for a statistical package.

We use JNI mechanism to import procedures written in Fortran, C and C++ languages. It helps to make Java classes which execute foreign language programs without much modification. We have imported some programs in TIMSAC (TIMe Series And Control) package (Akaike and Nakagawa, 1988) into Jasp. Although main Java programs can be used commonly on all operating systems, different shared libraries of foreign language programs are required for each operating systems. It damages platform independency of Jasp, and should be used carefully.

Copyright c 2000 by Project Jasp All Rights Reserved