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

Revision 907bf5c37e33318d1b4a089e4385e32e2bc58100 authored by Wesley Tansey on 23 June 2016, 01:57:13 UTC, committed by Wesley Tansey on 23 June 2016, 01:57:13 UTC
Added a simplified interface for fdr smoothing that only requires the data and the edges
1 parent 97c546a
  • Files
  • Changes
  • bd3d3c3
  • /
  • smoothfdr
  • /
  • signal_distributions.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.

  • revision
  • directory
  • content
revision badge
swh:1:rev:907bf5c37e33318d1b4a089e4385e32e2bc58100
directory badge Iframe embedding
swh:1:dir:a6c0fd806e00b75984345b63925b36633898d701
content badge Iframe embedding
swh:1:cnt:f7c091b757ea015e569b0876a66e82df06ee026a
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.

  • revision
  • directory
  • content
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 ...
signal_distributions.py
import matplotlib
matplotlib.use('Agg')
from matplotlib import cm, colors
import matplotlib.pyplot as plt
import numpy as np
from scipy.stats import norm

def alt1_pdf(x):
    return 0.48 * norm.pdf(x, -2, np.sqrt(1)) + 0.04 * norm.pdf(x, 0, np.sqrt(16)) + 0.48 * norm.pdf(x, 2, np.sqrt(1))

def alt2_pdf(x):
    return 0.4 * norm.pdf(x, -1.25, np.sqrt(2)) + 0.2 * norm.pdf(x, 0, np.sqrt(4)) + 0.4 * norm.pdf(x, 1.25, np.sqrt(2))

def alt3_pdf(x):
    return 0.3 * norm.pdf(x, 0, np.sqrt(0.1)) + 0.4 * norm.pdf(x, 0, np.sqrt(1)) + 0.3 * norm.pdf(x, 0, np.sqrt(9))

def alt4_pdf(x):
    return 0.2 * norm.pdf(x, -3, np.sqrt(0.01)) + 0.3 * norm.pdf(x, -1.5, np.sqrt(0.01)) + 0.3 * norm.pdf(x, 1.5, np.sqrt(0.01)) + 0.2 * norm.pdf(x, 3, np.sqrt(0.01))

def well_separated_pdf(x):
    return 0.5 * norm.pdf(x, -2.5, 1) + 0.5 * norm.pdf(x, 2.5, 1)

def flat_unimodal_pdf(x):
    return norm.pdf(x, 0, 3)

def alt1_noisy_pdf(x):
    return 0.48 * norm.pdf(x, -2, np.sqrt(1+1)) + 0.04 * norm.pdf(x, 0, np.sqrt(16+1)) + 0.48 * norm.pdf(x, 2, np.sqrt(1+1))

def alt2_noisy_pdf(x):
    return 0.4 * norm.pdf(x, -1.25, np.sqrt(2+1)) + 0.2 * norm.pdf(x, 0, np.sqrt(4+1)) + 0.4 * norm.pdf(x, 1.25, np.sqrt(2+1))

def alt3_noisy_pdf(x):
    return 0.3 * norm.pdf(x, 0, np.sqrt(0.1+1)) + 0.4 * norm.pdf(x, 0, np.sqrt(1+1)) + 0.3 * norm.pdf(x, 0, np.sqrt(9+1))

def alt4_noisy_pdf(x):
    return 0.2 * norm.pdf(x, -3, np.sqrt(0.01+1)) + 0.3 * norm.pdf(x, -1.5, np.sqrt(0.01+1)) + 0.3 * norm.pdf(x, 1.5, np.sqrt(0.01+1)) + 0.2 * norm.pdf(x, 3, np.sqrt(0.01+1))

def well_separated_noisy_pdf(x):
    return 0.5 * norm.pdf(x, -2.5, np.sqrt(2)) + 0.5 * norm.pdf(x, 2.5, np.sqrt(2))

def flat_unimodal_noisy_pdf(x):
    return norm.pdf(x, 0, np.sqrt(10))

def alt1_sample():
    u = np.random.random()
    if u <= 0.48:
        return np.random.normal(-2, np.sqrt(1))
    elif u <= 0.52:
        return np.random.normal(0, np.sqrt(16))
    return np.random.normal(2, np.sqrt(1))

def alt2_sample():
    u = np.random.random()
    if u <= 0.4:
        return np.random.normal(-1.25, np.sqrt(2))
    elif u <= 0.6:
        return np.random.normal(0, np.sqrt(4))
    return np.random.normal(1.25, np.sqrt(2))

def alt3_sample():
    u = np.random.random()
    if u <= 0.3:
        return np.random.normal(0, np.sqrt(0.1))
    elif u <= 0.7:
        return np.random.normal(0, np.sqrt(1))
    return np.random.normal(0, np.sqrt(9))
    
def alt4_sample():
    u = np.random.random()
    if u <= 0.2:
        return np.random.normal(-3, np.sqrt(0.01))
    elif u <= 0.5:
        return np.random.normal(-1.5, np.sqrt(0.01))
    elif u <= 0.8:
        return np.random.normal(1.5, np.sqrt(0.01))
    return np.random.normal(3, np.sqrt(0.01))

def well_separated_sample():
    u = np.random.random()
    if u <= 0.5:
        return np.random.normal(-2.5, 1)
    return np.random.normal(2.5, 1)

def flat_unimodal_sample():
    return np.random.normal(0, 3)
    
def test_pdf(x):
    return norm.pdf(x, 3, 1)

def test_sample():
    return np.random.normal(3, 1)

def plot_alts(filename):
    fig, axarr = plt.subplots(2,2)

    x = np.linspace(-6, 6, 1000)

    # Alt 1
    axarr[0,0].plot(x, pdf_alt1(x))
    axarr[0,0].set_title('Case 1')

    # Alt 2
    axarr[1,0].plot(x, pdf_alt2(x))
    axarr[1,0].set_title('Case 2')

    # Alt 3
    axarr[0,1].plot(x, pdf_alt3(x))
    axarr[0,1].set_title('Case 3')

    # Alt 4
    axarr[1,1].plot(x, pdf_alt4(x))
    axarr[1,1].set_title('Case 4')

    plt.savefig(filename, bbox_inches='tight')

if __name__ == '__main__':
    plot_alts('synthetic_alt_densities.pdf')
The diff you're trying to view is too large. Only the first 1000 changed files have been loaded.
Showing with 0 additions and 0 deletions (0 / 0 diffs computed)
swh spinner

Computing file changes ...

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