Introduction to Statistical Analysis/Scientific Calculation Rstats
I am currently creating a module called Rstats for statistical analysis and scientific calculation in Perl. The goal of Rstats is to implement the R language, which is a language for statistical analysis and scientific computing, on top of Perl.
Perl is a general-purpose language and is good at text processing. However, on the other hand, I am not good at statistical analysis and scientific calculation. One of the major causes is the absence of easy-to-use modules.
Therefore, we wanted to reduce the burden and enable learning by implementing the functions of the R language, which is familiar in statistical analysis, on Perl.
It seems that it will be a long way to implement, such as the huge amount of implementation, the implementation by fumbling, and the compatibility with the Perl language, so only the basic calculation part is documented first. , I will write it little by little.
I am currently studying physics, mathematics, information engineering, etc. because I think it is necessary to implement Rstats.
Install Rstats
Rstats can be easily installed and used from CPAN on both Windows and Unix. If you want to run it on Windows, please install ActivePerl or Strawbery Perl. If you have Perl 5.10.1 or higher, you can run it.
cpan Rstats
Or if cpanm is installed
cpanm Rstats
How to use
Easy to use.
use strict; use warnings; use Rstats; # vector my $x1 = c_ (1, 2, 3); my $x2 = c_ (5, 6, 7); my $x3 = -c_ (8, 9, 10); my $x4 = $x1 + ($x2 * $x3); print $x4; # Creating a vector containing 1 to 10 in the element my $x5 = C_ ('1:10'); print $x5; # Calculate sin my $x6 = c_ (pi/4, pi/2); my $x7 = r->sin($x6); print $x7;
You can create a vector with the " c_ " function. The created vector can perform four arithmetic operations.
You can automatically create a sequence of numbers with the " C_ " function. You can express 10 numbers from 1 to 10 with the expression "'1:10'".
The underscore after the function name, such as "c_" or "C_", is due to Perl's restrictions on single-letter functions. This is because in Perl, when you write "-c ()", the minus of the c function is not understood and is understood as the file operator "-c". This is a frequent mistake, so I gave up and named the functions "c_" and "C_".
Functions corresponding to the R language can be called from the " r " object as "r->sin(...)".
The output result is as follows.
[1] -39 -52 -67 [1] 1 2 3 4 5 6 7 8 9 10 [1] 0.707106781186547 1
Introduction to Rstats
This is an introduction to statistical analysis and scientific and technological calculations using Rstats. I will explain the basics.