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

swh:1:snp:7bb11892490e1dc1b1ff3be1d93f489dadb3e857
  • Code
  • Branches (1)
  • Releases (0)
    • Branches
    • Releases
    • HEAD
    • refs/heads/master
    No releases to show
  • 8306d99
  • /
  • test
  • /
  • hmrfPost.py
Raw File Download
Permalinks

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
content badge Iframe embedding
swh:1:cnt:827b610dae3a44685fd79faec3a66ca26f48e383
directory badge Iframe embedding
swh:1:dir:892f10df507d1f9e5b4f08f94035d8aa1fa69841
revision badge
swh:1:rev:c5b693d0a66e83c9387433b33c0eab481bd4a763
snapshot badge
swh:1:snp:7bb11892490e1dc1b1ff3be1d93f489dadb3e857
Citations

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: c5b693d0a66e83c9387433b33c0eab481bd4a763 authored by Wesley Tansey on 08 May 2020, 15:42:20 UTC
Fixed bug in easy that created too large a support for the alternative distribution
Tip revision: c5b693d
hmrfPost.py
import numpy as np
import scipy.stats as st
import csv
import sys
from smoothfdr.utils import calc_fdr

expdir = sys.argv[1]

with open(expdir + 'buffer_lis.csv', 'rb') as f:
    reader = csv.reader(f, delimiter=' ')
    lis = np.array([float(x) for x in reader.next() if x != ''])

# Try treating the LIS as a prior probability of coming from the null hypothesis
# data = np.loadtxt(expdir + 'flatdata.csv', delimiter=',').flatten()
# params = np.loadtxt(expdir + 'buffer_estimate_result.csv')[2:]
# means = params[0::3]
# variances = params[1::3]
# mix_weights = params[2::3]
# sigprob = lambda x: np.sum([w * st.norm.pdf(x, loc=m, scale=np.sqrt(v)) for w, m, v in zip(means, variances, mix_weights)], axis=0)
# nullprob = lambda x: st.norm.pdf(x)
# postprob = (sigprob(data) * (1-lis)) / (sigprob(data) * (1-lis) + nullprob(data) * lis)
# discovered = calc_fdr(postprob, 0.1)

# Step-up procedure for LIS
alpha = 0.1 # FDR level
lis_orders = np.argsort(lis)[::1]
lis_sum = 0
max_i = len(lis)
for i, s in enumerate(lis_orders):
    lis_sum += lis[s]
    threshold = 1. / (1. + i) * lis_sum
    if threshold > alpha:
        max_i = i
        break

# Save the discoveries to file
discovered = np.zeros((128,128))
selected = lis_orders[:max_i]
discovered = discovered.flatten()
discovered[selected] = 1
discovered = discovered.reshape((128,128))
np.savetxt(expdir + 'hmrf_discoveries.csv', discovered, delimiter=',', fmt='%d')

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— Contact— JavaScript license information— Web API

back to top