[ 
https://issues.apache.org/jira/browse/BEAM-13080?focusedWorklogId=677937&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-677937
 ]

ASF GitHub Bot logged work on BEAM-13080:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 05/Nov/21 22:49
            Start Date: 05/Nov/21 22:49
    Worklog Time Spent: 10m 
      Work Description: InigoSJ commented on pull request #15912:
URL: https://github.com/apache/beam/pull/15912#issuecomment-962264660


   > Looking at #15753, the question to answer:
   > 
   > Is `random.getrandbits(32)` equivalent to `random.randint(0, (1 << 32) - 
1)`?
   
   I have ran a quick test and the distribution is the same, hitting the same 
low and high values:
   
   ```
   def test_randoms(bits, M, epsilon = 0.05):
       bit_d = collections.defaultdict(lambda: 0)
       normal_d = collections.defaultdict(lambda: 0)
   
       for _ in range(M):
           bit_d[random.getrandbits(bits)] += 1
           normal_d[random.randint(0, (1 << bits) - 1)] += 1
   
       for key in bit_d:
           div = bit_d[key] / normal_d[key]
           if not 1 - epsilon < div < 1 + epsilon:
               print(bit_d[key], normal_d[key], key, div)
               return False
       return True
   
   test_randoms(8, 10 * 10**6)
   ```
   Returns True
     
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 677937)
    Time Spent: 4.5h  (was: 4h 20m)

> Specify numBuckets in Python Reshuffle
> --------------------------------------
>
>                 Key: BEAM-13080
>                 URL: https://issues.apache.org/jira/browse/BEAM-13080
>             Project: Beam
>          Issue Type: New Feature
>          Components: sdk-py-core
>            Reporter: Inigo San Jose Visiers
>            Priority: P2
>          Time Spent: 4.5h
>  Remaining Estimate: 0h
>
> While Java has `withNumBuckets` to set the amount of generated keys, Python 
> doesn't.
> This is particularly need when your input data is not so high and you need to 
> take advantage for DoFn methods `start / finish bundle`.
> https://beam.apache.org/releases/javadoc/2.33.0/org/apache/beam/sdk/transforms/Reshuffle.ViaRandomKey.html#withNumBuckets-java.lang.Integer-



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to