Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enh] Add quasi-random sampling: Halton #828

Merged
merged 2 commits into from
Apr 2, 2024

Conversation

HydrogenSulfate
Copy link
Collaborator

@HydrogenSulfate HydrogenSulfate commented Apr 1, 2024

PR types

Others

PR changes

APIs

Describe

  1. 添加 Halton 准随机采样方法(想比random伪随机方法,生成的点会更均匀),如下所示
import ppsci


rect = ppsci.geometry.Rectangle([-1, -1], [1, 1])

round_ = ppsci.geometry.Disk([0, 0], 1.0)

rect_halton_points = rect.sample_interior(
    10000,
    "Halton",
    criteria=lambda x, y: (x > 0) & (y > -0.5),
)
round_halton_points = round_.sample_interior(
    10000,
    "Halton",
    criteria=lambda x, y: (x > 0.5) & (y < 0.5),
)

ppsci.visualize.save_vtu_from_dict(
    "rect_halton_points.vtu",
    rect_halton_points,
    ("x", "y"),
    ("x", "y"),
)
ppsci.visualize.save_vtu_from_dict(
    "round_halton_points.vtu",
    round_halton_points,
    ("x", "y"),
    ("x", "y"),
)

image
image

Copy link

paddle-bot bot commented Apr 1, 2024

Thanks for your contribution!

Copy link
Collaborator

@zhiminzhang0830 zhiminzhang0830 left a comment

Choose a reason for hiding this comment

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

LGTM

@zhiminzhang0830 zhiminzhang0830 merged commit 11b625f into PaddlePaddle:develop Apr 2, 2024
3 of 4 checks passed
@HydrogenSulfate HydrogenSulfate deleted the add_halton branch April 2, 2024 08:48
huohuohuohuohuo123 pushed a commit to huohuohuohuohuo123/PaddleScience that referenced this pull request Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants