{"id":20508289,"url":"https://github.com/citrineinformatics/sprandom","last_synced_at":"2026-04-21T13:32:55.423Z","repository":{"id":59704233,"uuid":"498865439","full_name":"CitrineInformatics/sprandom","owner":"CitrineInformatics","description":"A splittable, serializable psuedorandom number generator in Scala.","archived":false,"fork":false,"pushed_at":"2023-08-24T20:19:41.000Z","size":47,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":15,"default_branch":"main","last_synced_at":"2025-01-16T08:19:25.010Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CitrineInformatics.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-06-01T19:05:10.000Z","updated_at":"2022-09-16T19:04:37.000Z","dependencies_parsed_at":"2022-09-20T12:26:08.029Z","dependency_job_id":null,"html_url":"https://github.com/CitrineInformatics/sprandom","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CitrineInformatics%2Fsprandom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CitrineInformatics%2Fsprandom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CitrineInformatics%2Fsprandom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CitrineInformatics%2Fsprandom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CitrineInformatics","download_url":"https://codeload.github.com/CitrineInformatics/sprandom/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242111465,"owners_count":20073435,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-15T20:17:56.016Z","updated_at":"2026-04-21T13:32:54.088Z","avatar_url":"https://github.com/CitrineInformatics.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SpRandom\n\nSplittable, serializable pseudorandom number generation in Scala.\n\nThe SpRandom package produces random numbers that are reproducible in a multi-threaded context.\nIt also allows the random state to be serialized and deserialized.\n\nSpRandom's `Random` class is built on top of the `java.util.SplittableRandom` class.\nIt exposes the following features:\n* A `zip` method that facilitates reproducibility in a multi-threaded context\n* Serializability by persisting the underlying seed (SplittableRandom is not serializable)\n* Multiple, convenient ways to instantiate a random state\n* A variety of convenience methods to generate pseudorandom outcomes\n\n## Usage\n\nA `Random` object can be instantiated from an integer seed, a long seed, or another `Random` object.\n\n```scala\nimport io.citrine.random.Random\n\nval rng = Random(17L)\nval rng2 = rng.split() // an independent stream\nval uniformRandom = rng.between(1.5, 2.5) // draw from a uniform distribution between 1.5 and 2.5\nval normalRandom = rng.nextGaussian(mean = 5.0, stdDev = 0.1) // draw from a normal with mean 5.0 and standard deviation 0.1\nval orderedVector = (1 to 10).toVector\nval shuffledVector = rng.shuffle(orderedVector) // random permutation of the range (1 to 10)\n```\n\nTo get reproducible results in a multi-threaded context, use `.zip`.\nImagine that we have some sequence, `items`, that we want to process in parallel.\nProcessing is done by the stochastic, reproducible method `heavyStochasticComputation`.\nThe following call is then reproducible.\n\n```scala\nrng.zip(items).par.map { case (thisRng, item) =\u003e heavyStochasticComputation(item, thisRng) }\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcitrineinformatics%2Fsprandom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcitrineinformatics%2Fsprandom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcitrineinformatics%2Fsprandom/lists"}