Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

https://github.com/kussell-lab/mcorr
23 January 2022, 09:11:33 UTC
  • Code
  • Branches (5)
  • Releases (0)
  • Visits
    • Branches
    • Releases
    • HEAD
    • refs/heads/2019natmethods
    • refs/heads/2021biorxiv
    • refs/heads/dev
    • refs/heads/master
    • refs/heads/x
    No releases to show
  • de1d592
  • /
  • bootstrap.go
Raw File Download
Take a new snapshot of a software origin

If the archived software origin currently browsed is not synchronized with its upstream version (for instance when new commits have been issued), you can explicitly request Software Heritage to take a new snapshot of it.

Use the form below to proceed. Once a request has been submitted and accepted, it will be processed as soon as possible. You can then check its processing state by visiting this dedicated page.
swh spinner

Processing "take a new snapshot" request ...

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
  • revision
  • snapshot
origin badgecontent badge Iframe embedding
swh:1:cnt:14b3723c394bf1748cd415e6da9c8e413e28b026
origin badgedirectory badge Iframe embedding
swh:1:dir:de1d592a1547b8310297927179ce3a8afab1a4c9
origin badgerevision badge
swh:1:rev:e0c8c6661b6c23ef96b5d2e093d73c106367411c
origin badgesnapshot badge
swh:1:snp:bc0e5aa6513599be660f007d7b46ba12cce5b7e5

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
  • revision
  • snapshot
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Tip revision: e0c8c6661b6c23ef96b5d2e093d73c106367411c authored by Asher Preska Steinberg on 16 September 2021, 15:23:44 UTC
Cleaning up branch
Tip revision: e0c8c66
bootstrap.go
package mcorr

import "math/rand"
import "math"

// Bootstrap for one bootstrapping instance.
type Bootstrap struct {
	ID          string
	sampleRatio float64
	collector   *Collector
	isRandom    bool
}

// NewBootstrap creates a new Boot, given id and sample ratio.
// Sample ratio must be a float64 from 0 to 1.
// By default, bootstrap should do random sampling.
func NewBootstrap(id string, sampleRatio float64) *Bootstrap {
	b := Bootstrap{}
	b.ID = id
	if sampleRatio < 0 {
		sampleRatio = 0
	} else if sampleRatio > 1 {
		sampleRatio = 1
	}
	b.sampleRatio = sampleRatio
	b.collector = NewCollector()
	b.isRandom = true
	return &b
}

// SetRandom set random status
func (b *Bootstrap) SetRandom(r bool) {
	b.isRandom = r
}

// Add add one result into the Bootstrap.
func (b *Bootstrap) Add(results CorrResults) {
	if b.isRandom {
		k := poisson(b.sampleRatio)
		for i := 0; i < k; i++ {
			b.collector.Add(results)
		}
	} else {
		b.collector.Add(results)
	}

}

// Results return final results.
func (b *Bootstrap) Results() (results []CorrResult) {
	return b.collector.Results()
}

func poisson(lambda float64) int {
	L := math.Pow(math.E, -lambda)
	k := 0
	p := 1.0
	for p > L {
		k++
		p *= rand.Float64()
	}
	return k - 1
}

back to top

Software Heritage — Copyright (C) 2015–2025, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API