the R (programming language) library for random variable operations Does anyone know if the R library provides tools to perform some basic algebraic operations on r.v?
Matlab doesn't have this (as far as I know), but if anyone knows about the existence of an extension to do this it would be great.
Thanks for your kindness
 A: If by "algebraic operations on [random variables]" you mean computer algebra systems (CAS) which allows computation and manipulation (i.e. symbolic computation) of mathematical expressions, then I think there are some tools available that interface with other software. Examples are the rSymPyand Ryacas packages.
If not, R supports regular algebraic operations on realized random variables. E.g. consider the following R code:
rv1 <- rnorm(1000, mean = 4.5, sd = 3) # Draw 1000 normal distributed values
rv2 <- rchisq(1000, df = 1)
new.rv <- cos(log(rv1^2 + 5))*rv2 # Some weird transformation
hist(new.rv)  # Plot a histogram of the new r.v.

A: I don't know what you mean by r.v. But all you seem to want is to be to be able to calculate the sum, product, ratio, mean, standard deviation, etc. That's pretty straight forward in R (also I suggest you run R in Rstudio because you can save your graphical plots.) Anyway, how about some data.
R is a pretty straight forward language as you can see all your operations are done in parentheses. 

x = c(1:10) # where c is for concatenating # so this prints out 10 numbers from 1 to 10. 
x 
x = c(1, 3, 8, 13, 21) # So this prints out specific numbers. 
  x
  Now, lets work with the data. 
sum(x), so R just computed the sum of all the numbers in the set. 
  [1] 46 # That's 1^2 + 3^2 + 8^2 + 13^2 + 21^2 

What if I want the sum of the squared numbers?

sum(x^2) # computes 1^2 + 3^2 + 8^2 + 13^2 + 21^2
  [1] 684 
another way to do that ...
y = x^2 
  sum(y)
  [1] 684

You want the median? 

median(x)
  [1] 9.2
How about the range?
range(x) 
  [1] 1 21 # so the range is 1 to 21. 
You can get a lot of information by just running.
summary(x) 

You want to use R like a calculator?

2 * 3 
  3^2 
  prod(1:5) # Just calculated 1 * 2 * 3 * 4 * 5 = 120 or 5! 
  [1] 120 

Check your variables:

ls() 
  [1] x y 
remove a variable.
rm(y)
variable y is gone

Now let's make a data frame which is basically an excel spreadsheet of columns. 
I will call this data frame df. 

df <- data.frame(x) # or df = data.frame(x) 

Lets look at our dataframe in real time.

View(x) 
  Now let's add a new column to it, and call it y. 
df$y = 2 * (df$x)^2 + 3
as you can see what is in column y is now what is in x squared times 2 and then plus 3. Now, let's graph this. # Note: The dollar signs refer to columns within the data frame.

Essentially I am graphing the function: y = 2 * (x^2) + 3
using real data points relative to each other.
Let's make the graph.

plot(df$x, df$y, main = "My first Graph in R", xlab = "x", ylab = "y", col = "darkorchid4", pch = 16)
Everything except for df$x & df$y are just aesthetics.

Now let us fit a spline cure to it. It won't be perfect but its better than a straight line which purely doesn't fit the dataset.

lines(smooth.spline(df$x, df$y))

Alright now let's calculate the area under this curve with respect to x given
which is from 1 to 21. We don't have to specify the range. R already knows what it is.
Google how to install a package in R or in Rstudio click tools, install packages, and then type pracma in the package, and then load the package. 

library(pracma) # We need pracma to give us the function trapz which will calculate the area under our curve trapezoidal area approximation. 
trapz(df$x, df$y) 
  [1] 6490

That's a pretty good approximation of (from 1 to 21) ∫(2x^2 + 3)dx 
= 6233 + (1 / 3) 
If I had less gaps in x, the integral would be great, and yes, R can integrate functions numerically.

fx <- function(x) {2 * x^2 + 3}
integrate(fx, lower = 1, upper = 21)
  6233.333 with absolute error < 6.9e-11

As you can see R can do a lot of things, and I haven't even shown you all the statistics it can do. One of the great things about R is that it is very useful for data-mining which is why many bioinformaticians use it. A function that takes 21 lines or so to write in C, can be executed in R in one line without having to make your own function. 
By the way, in R read up on the plot function. See what arguments it accepts. 

?plot # notice the question mark. 

To learn R I suggest looking at the data provided in R and doing simple examples to see what happens.

data(Indometh) # these are built in datasets. 
  data(women)
  women 
or just ...
data() 
and scroll through the datasets.

If you doubt R's capability to do something. You are wrong. It can do it in 1 to 3 lines of code. 
Now I'm going to give you some free books on R which are legal because they # are distributed by R which is free software and the books are under the GNU license so learn yourself something. R distributes these books
Using R for Introductory Statistics:
https://cran.r-project.org/doc/contrib/Verzani-SimpleR.pdf
An R book that isn't a lot of fluff! Solving Epidemiology problems with R!
ftp://cran.r-project.org/pub/R/doc/contrib/Epicalc_Book.pdf
