#18269: A new structure for experimentation on decoding: communication channels
-------------------------+-------------------------------------------------
       Reporter:         |        Owner:
  dlucas                 |       Status:  needs_work
           Type:         |    Milestone:  sage-6.7
  enhancement            |   Resolution:
       Priority:  major  |    Merged in:
      Component:         |    Reviewers:
  coding theory          |  Work issues:
       Keywords:         |       Commit:
        Authors:         |  5f31c5cef52b9b0bdbd905f4ff132e344446e766
Report Upstream:  N/A    |     Stopgaps:
         Branch:         |
  u/dlucas/channels      |
   Dependencies:         |
-------------------------+-------------------------------------------------

Comment (by vdelecroix):

 > 13. I would rather implement `StaticErrorRateChannel.transmit_unsafe` as
 > {{{
 > def transmit_unsafe(self, msg):
 >     w = msg.copy()
 >     V = self.input_space()
 >     for i in sample_range(V.dim(), randint(*self.nb_errors())):
 >         w[i] = V.random_element()
 >     return w
 > }}}
 >   it would be more direct. Moreover it shows that `sample_range` would
 better be an iterator instead of returning a list. By the way, this
 function `sample_range` has currently linear complexity in `n`, isn't it
 possible to make it linear in `k`?

 Yes it is (the solution is not exactly linear though)
 {{{
 sage: S = Subsets(100,4)
 sage: timeit("S.random_element()")
 625 loops, best of 3: 54.2 µs per loop
 sage: timeit("sample_range(100,4)")
 625 loops, best of 3: 57.7 µs per loop
 sage: S = Subsets(1000,4)
 sage: timeit("S.random_element()")
 625 loops, best of 3: 61.2 µs per loop
 sage: timeit("sample_range(1000,4)")
 625 loops, best of 3: 510 µs per loop
 }}}
 It is roughly the same speed for `n=100` but for `n=1000` yours is twice
 slower.

--
Ticket URL: <http://trac.sagemath.org/ticket/18269#comment:12>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to