Skip to content

++Tutorial: "Mathematical Transformations of Spatially Balanced Samples"#364

Open
falkmielke wants to merge 6 commits into
masterfrom
transform_spatial_balanced
Open

++Tutorial: "Mathematical Transformations of Spatially Balanced Samples"#364
falkmielke wants to merge 6 commits into
masterfrom
transform_spatial_balanced

Conversation

@falkmielke
Copy link
Copy Markdown
Contributor

@falkmielke falkmielke commented Aug 23, 2025

Description

A brief writeup of some useful tweaks I first implemented here for the MNM project.
I found this of general relevance, and spiced it up with references to spatially balanced sampling and basic application of functional programming.

Task list

  • My tutorial or article is placed in a subfolder of tutorials/content/
  • The novel tutorial has a meaningful name, in relation to the content of the tutorial.
  • The filename of my tutorial or article is index.md. In case of an Rmarkdown tutorial I have knitted my index.Rmd to index.md (both files are pushed to the repo).
  • yaml header:
    • (recommended) I am included as author in the authors yaml tag, using [MY_AUTHOR_ID]. An author information file exists in <tutorials>/data/authors/<author>.toml.
    • I have added categories to the YAML header and my category tags are from the list of categories.
    • I have included meaningful and applicable tags (i.e. keywords) in the YAML header to improve the visibility of the new tutorial (see the tags listed in the tutorials website side bar).
    • The date is in format YYYY-MM-DD and adjusted.
  • (recommended) I have previewed this PR locally (see steps below; ask previous contributors for help) and confirmed that the new content renders as expected.

Previewing the pull request

Thanks to GitHub Actions, an artifact (=zip file) of the rendered website is automatically created for each pull request.
This provides a way to preview how these updates will look on the website, useful to contributors and reviewers.

Instructions to preview the updated website

  1. On the PR page, you can find a "details" link under "checks - On PR, build the site and ...". Go there, click on the top link in the left sidebar ("Summary"), and download the generated artifact at the bottom of the page.
  2. Decompress it into a target directory, e.g. Downloads/tutorials_preview.
  3. To preview the website, use a program which can serve http sites on your local machine. One such option is the servr package in R: & '\C:\Program Files\R\R-4.4.2\bin\Rscript.exe' -e "servr::httd('./tutorials_preview')" -p8887 (make sure to adjust the path to your Rscript.exe; on Linux, simply use Rscript -e [...]).
  4. Point your browser to http://localhost:8887.
  5. Review the updated website. As a contributor, you can push extra commits to update the PR. As a reviewer, you can accept/refuse/comment the PR.

Note: for step 3, you can use any other simple HTTP server to serve the current directory, e.g. Python http.server: python -m http.server 8887 --bind localhost --directory path/to/tutorials_preview

Alternative: Locally Building the Site

Alternatively, you can build the entire site locally (see the README for instructions); the Hugo preview server will update changes on the fly.
This requires Hugo to be installed on your computer.

@falkmielke falkmielke requested a review from florisvdh August 25, 2025 05:31
Copy link
Copy Markdown

@bserrien bserrien left a comment

Choose a reason for hiding this comment

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

Hi Falk, this is a very interesting tutorial! I am not an expert in spatial sampling (but I'm trying to learn it on my own), but everything is conceptually clear to me (I'll have to deal with the mathematics of Halton sequences another time). As a non-expert, I would mainly benefit from having more examples in the tutorial, maybe in the form of references to specific applications. Some examples:

  • (3) Choose Your Distribution Pattern: And in many applications, it is a valid strategy to give points closer to the center a higher chance of being chosen [?? EXAMPLE ??], or to have a sampling pattern that reduces likelihood with distance from center, or just the opposite (i.e. bias towards the rim) [?? EXAMPLE ??].
  • Spatial Balance - in a Weird Way: Close to the center, it is high, but it reduces towards the edges of our circle. Logical, if you think about it: the orbits close to the center are much shorter, yet they house equally many points as the distant orbits. This outcome might be fine in some situations [?? EXAMPLE ??], but undesired in others [?? EXAMPLE ??].
  • If you would have real-life examples for the special variants (line 508 and further) that would be cool, but the tutorial is fine without.

On line 339 there is a typo: it refers to apply_transform but it was coded as apply_trafo.

Thanks for writing this nice tutorial!

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.

2 participants