Announcement: MonetDB-rmath
Dear all, A first version for MonetDB-rmath is now available. It includes approximately 90% of the functions in Rmath.h, including [rpdq](norm|unif|gamma|beta|lnorm|chisq|nchisq|f|t|binom|cauchy|exp|geom|hyper| nbinom|pois|weibull|logis|wilcox|signrank) and another 40 functions. The current implementation uses m4 for code generation and requires the r-mathlib package under Debian. One can clone the GitHub repository and install using: git clone https://github.com/mclements/MonetDB-rmath.git cd MonetDB-rmath make sudo make install You will then need to use a fresh database. An example script is: -- calculate the quantile and cumulative distribution function for a unit normal select qnorm(0.025,0,1), pnorm(-1.96,0,1); -- calculate E(Z^2) for Z~Normal(0,1) select sum(R_pow(value,2)*0.01*dnorm(value,0,1)) from sys.generate_series(-5.0,5.0,0.01); -- random numbers select set_seed(1,2); select rpois(value*0+100) from sys.generate_series(1,10); -- ok select rpois(100) from sys.generate_series(1,10); -- repeats the values 10 times:-< All of the functions are currently scalars. Next steps include adding BAT functions, including some of the constants at the beginning of Rmath.h, and adding some statistical tests. As an example, I have included poissonci(y,boundary) for an exact Poisson confidence interval for count y for a specific boundary (1=left, 2=right) with default confidence level of 95%: select poissonci(10,1), poissonci(10,2); The equivalent code in R would be poisson.test(10). For confidence intervals, it would be nice to have a type that is a pair of doubles. Sincerely, Mark.
Sjoerd: than you for your earlier guidance. As a follow-up: first, can I write the random number functions to give a different value for each row (see example below)? Second, is there a simple pair type available - or is there a better way to return multiple columns (e.g. as per MADlib)? Kindly, Mark. On 05/08/2018 09:36 AM, Mark Clements wrote:
select rpois(100) from sys.generate_series(1,10); -- repeats the value
On 09/05/18 13:32, Mark Clements wrote:
Sjoerd: than you for your earlier guidance.
As a follow-up: first, can I write the random number functions to give a different value for each row (see example below)? Second, is there a
It may work if you declare the MAL function (rpois here) as "unsafe": unsafe command rpois(v:dbl) :dbl ... By default, functions are assumed to return the same value every time, so multiple calls with the same parameters can be removed. But if the function is unsafe, the optimizer knows this is an unsafe assumption.
simple pair type available - or is there a better way to return multiple columns (e.g. as per MADlib)?
MAL functions can return multiple values, including multiple BATs. If the BATs are aligned (same length, same hseqbase), the SQL layer can be coerced into turning the result into a SQL table. See e.g. the SQL function sys.storage() and its MAL implementation sql.storage in the MonetDB sources. Or is this not what you're asking?
Kindly, Mark.
On 05/08/2018 09:36 AM, Mark Clements wrote:
select rpois(100) from sys.generate_series(1,10); -- repeats the value
_______________________________________________ users-list mailing list users-list@monetdb.org https://www.monetdb.org/mailman/listinfo/users-list
-- Sjoerd Mullender
participants (2)
-
Mark Clements
-
Sjoerd Mullender