Skip to content

ARROW-12404: [C++] Implement "random" nullary function that generates uniform random between 0 and 1 - #11864

Closed
asuhan wants to merge 15 commits into
apache:masterfrom
asuhan:asuhan/random_nullary
Closed

asuhan wants to merge 15 commits into
apache:masterfrom
asuhan:asuhan/random_nullary

Conversation

@asuhan

@asuhan asuhan commented Dec 6, 2021

Copy link
Copy Markdown
Contributor

No description provided.

@github-actions

github-actions Bot commented Dec 6, 2021

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Dec 6, 2021

Copy link
Copy Markdown

⚠️ Ticket has not been started in JIRA, please click 'Start Progress'.

@asuhan
asuhan force-pushed the asuhan/random_nullary branch 3 times, most recently from 1334b15 to d6d83ba Compare December 6, 2021 09:00
@asuhan
asuhan force-pushed the asuhan/random_nullary branch from d6d83ba to f188f79 Compare December 6, 2021 09:07
Comment thread cpp/src/arrow/compute/kernels/random.cc Resolved
@pitrou

pitrou commented Dec 6, 2021

Copy link
Copy Markdown
Member

By the way, it's not obvious the complicated generate_canonical implementation is useful. Here is what Numpy uses:
https://github.com/numpy/numpy/blob/fefe3309c8253726d37c184137a2e058a14b12cc/numpy/random/_common.pxd#L67-L68

@pitrou

pitrou commented Dec 6, 2021

Copy link
Copy Markdown
Member

That said, it may compile down to the same formula after optimizations. I can't tell for sure.

@cyb70289

cyb70289 commented Dec 7, 2021

Copy link
Copy Markdown
Contributor

That said, it may compile down to the same formula after optimizations. I can't tell for sure.

+1 for the simple implementation. I believe they are same, at least in theory. It's nothing more than RNG64()/(2^64) or RNG32()/(2^32).

@asuhan
asuhan force-pushed the asuhan/random_nullary branch 3 times, most recently from f41d9a4 to 9d327a4 Compare December 9, 2021 08:33
@asuhan
asuhan marked this pull request as ready for review December 9, 2021 08:35
@asuhan
asuhan force-pushed the asuhan/random_nullary branch from 9d327a4 to f96adea Compare December 9, 2021 08:48
@asuhan

asuhan commented Dec 9, 2021

Copy link
Copy Markdown
Contributor Author

Simplified the formula and made the seed initialization static, I think it's ready for review now.

@asuhan
asuhan force-pushed the asuhan/random_nullary branch 2 times, most recently from b1b7089 to aa13afe Compare December 9, 2021 09:41
Comment thread cpp/src/arrow/compute/kernels/random.cc Resolved
Comment thread cpp/src/arrow/compute/kernels/random.cc Resolved
@asuhan
asuhan force-pushed the asuhan/random_nullary branch 6 times, most recently from 9689824 to fa81409 Compare December 16, 2021 08:32
@asuhan

asuhan commented Dec 16, 2021

Copy link
Copy Markdown
Contributor Author

I've made it return an array, with the length in the options.

Comment thread cpp/src/arrow/compute/kernels/random.cc Resolved
Comment thread cpp/src/arrow/compute/kernels/random.cc Resolved
Comment thread cpp/src/arrow/compute/kernels/random.cc Resolved
Comment thread cpp/src/arrow/compute/registry.cc Resolved
@cyb70289

Copy link
Copy Markdown
Contributor

Please rebase to latest master branch and fix merge conflicts.

@asuhan
asuhan force-pushed the asuhan/random_nullary branch 2 times, most recently from e356e9f to 51d01e3 Compare December 27, 2021 04:41
@asuhan
asuhan force-pushed the asuhan/random_nullary branch from 51d01e3 to 7cb7031 Compare December 29, 2021 22:34
@asuhan

asuhan commented Dec 29, 2021

Copy link
Copy Markdown
Contributor Author

Any additional feedback on this? I think I've addressed all comments

@cyb70289 cyb70289 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks @asuhan !
I created jira issue to track python bind
https://issues.apache.org/jira/browse/ARROW-15219

@cyb70289

Copy link
Copy Markdown
Contributor

@pitrou, do you have other comments?

@pitrou pitrou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 from me. I just pushed two minor changes.

@pitrou pitrou closed this in ceaed97 Dec 30, 2021
@pitrou

pitrou commented Dec 30, 2021

Copy link
Copy Markdown
Member

Thank you very much for this, @asuhan !

@ursabot

ursabot commented Dec 30, 2021 •

Copy link
Copy Markdown

Benchmark runs are scheduled for baseline = ab9528e and contender = ceaed97. ceaed97 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Finished ⬇️0.0% ⬆️0.0%] ec2-t3-xlarge-us-east-2
[Finished ⬇️0.45% ⬆️0.0%] ursa-i9-9960x
[Failed ⬇️0.31% ⬆️0.09%] ursa-thinkcentre-m75q
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python. Runs only benchmarks with cloud = True
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

@kou

kou commented Dec 31, 2021

Copy link
Copy Markdown
Member

@github-actions crossbow submit debian-bullseye-amd64

@github-actions

Copy link
Copy Markdown

Revision: 4af2978

Submitted crossbow builds: ursacomputing/crossbow @ actions-1357

Task Status
debian-bullseye-amd64 Github Actions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants