You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mahout.apache.org by "Dmitriy Lyubimov (JIRA)" <ji...@apache.org> on 2014/07/29 19:46:53 UTC

[jira] [Commented] (MAHOUT-1599) Add rand() operator to math-scala

    [ https://issues.apache.org/jira/browse/MAHOUT-1599?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14078061#comment-14078061 ] 

Dmitriy Lyubimov commented on MAHOUT-1599:
------------------------------------------

there's a bunch of ephemeral views in Matrices class that provide it. Our ALS and SSVD stuff uses it a lot. E.g. a view with values  from U(-1,1) 
{code}
     rndView = Matrices.symmetricUniformView(...)
{code}

if you want to materialize a random view (as a concrete modifiable matrix) you can clone it in a matrix 

{code}
     rndView = Matrices.symmetricUniformView(...) cloned
{code}

I think there's currently support for U(-1,1), U(0,1) and N(0,1) matrix views.

Matrices also (i believe) contain methods that accept functions populating views. (functions must provide idempotent filling of course in order for view to work). 

On top of it, there's some very brief functional support in math-scala too. 

There is a slight inconsistency in a sense that there are mahout-math notion of functions, which are not compatible with scala functions (and there's, as it stands, no implicit conversion for them). But it is generally also possible to populate a dense matrix with a function literal in scala as well, e.g. : 

{code}
   rndA = new DenseMatrix(m,n) := { (r,c,v) => rnd.nextDouble }
{code}


As such, i think this patch is redundant 

> Add rand() operator to math-scala
> ---------------------------------
>
>                 Key: MAHOUT-1599
>                 URL: https://issues.apache.org/jira/browse/MAHOUT-1599
>             Project: Mahout
>          Issue Type: Improvement
>          Components: Math
>    Affects Versions: 0.9
>            Reporter: Felix Schüler
>            Priority: Trivial
>              Labels: dsl, math, operator, random, scala
>         Attachments: MAHOUT-1599.patch
>
>
> I was looking at the scala-math operators and missed a rand(m, n) operator that generates a m x n matrix filled with random numbers.
> I wanted random numbers from a uniform distribution over a specific interval so I implemented a simple uniform random number generator.
> the rand(m, n, r) function takes any AbstractSamplerFunction and fills the matrix entries with the numbers generated by its sample() method.



--
This message was sent by Atlassian JIRA
(v6.2#6252)