Macaulay2 / Macaulay2/M2

Add random(Sequence, Ring) to Core for generating several random elements at once

Open Beginner friendly
#4,540 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bugs directory Core
Dominant language
Macaulay2
Stars
435
Forks
297
Avg merge
4d 20h
Merged PRs (30d)
11

Description

This issue was triaged from bugs/dan/0.1-random-ring-elements, one of the 857 files removed from the pre-GitHub bugs/ tree by d2c8d27826 and catalogued in #36. The commentary below was written by Claude (Claude Opus 5, via Claude Code), not by @d-torrance, whose account posted it -- please weigh it accordingly.

The original file, verbatim
add to Core:

    i38 : random(Sequence,Ring) := o -> (degs,R) -> for d in deepSplice degs list random(d,R);

    i39 : random((4:1,3:2),R)

	   9   5   3      6 2  7 2  5 2
    o39 = {-x, -x, -x, x, -x , -x , -x }
	   2   6   2      7    9    6

    o39 : List

    i40 : random((4:{1},3:2),R)

	      5   1   7   3 2   2  5 2
    o40 = {x, -x, -x, -x, -x , x , -x }
	      4   5   9   8        4

    o40 : List
Where it stands today

Not added: lookup(random, Sequence, Ring) is null, and random((4:1, 3:2), R) errors.

The file supplies the implementation
random(Sequence, Ring) := o -> (degs, R) -> for d in deepSplice degs list random(d, R)

and the deepSplice is what makes the mixed form work, since it flattens degree lists as well as
repetitions:

random((4:1, 3:2), R)        -- four of degree 1, three of degree 2
random((4:{1}, 3:2), R)      -- same, with a multidegree written as a list
Why it belongs in Core

Generating several random elements of given degrees is a two-line idiom every package writes for itself,
and the sequence spelling (4:1, 3:2) reads better than the apply/join it replaces. There is no
mathematical decision to make here — only whether Core wants the method.

Not a duplicate

#877 and #4161 both concern the one-argument random(List); #4161 wants it to mean "a random
element", with shuffle(List) taking over the permuting. This would add a two-argument form alongside
that, so it is worth cross-referencing there rather than merging.

open · disposition issue · source of truth: bug-triage/catalog.tsv

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in Core at the random(Sequence, Ring) method entry point and inspect lookup(random, Sequence, Ring), which is currently null. Use the two documented examples, random((4:1, 3:2), R) and random((4:{1}, 3:2), R), to verify that both forms generate the expected list of random elements.

Written by the indexing model from the issue text.

Assessment

Domain
backend
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.