PIXELBANKv9.1.0
Menu

SNR from Continuous Log-SNR

Problem Statement

Continuous-time diffusion often works directly with lambda = log SNR. Given a log-SNR value, recover alpha_bar, SNR, and the noise standard deviation for the variance-preserving (VP) process.

Background

For the VP process, alpha_bar = sigmoid(lambda) because lambda = log(alpha_bar/(1-alpha_bar)) is exactly the logit of alpha_bar. From there:

αˉ=σ(λ),SNR=eλ,σnoise=1−αˉ\bar{\alpha} = \sigma(\lambda), \qquad \text{SNR} = e^{\lambda}, \qquad \sigma_{\text{noise}} = \sqrt{1 - \bar{\alpha}}

Your Task

Implement:

def from_log_snr(lam):

Return a dict with "alpha_bar", "snr", "sigma", each rounded to 6 decimals.

Input Format

  • lam (float): the log-SNR value.

Output Format

  • A dict of three floats.

Sample

print(from_log_snr(0.0))

Output:

{'alpha_bar': 0.5, 'snr': 1.0, 'sigma': 0.707107}

Example:

Input:
print(from_log_snr(0.0))
Output:
{'alpha_bar': 0.5, 'snr': 1.0, 'sigma': 0.707107}
Reasoning:
  • Compute αˉ\bar{\alpha} using the sigmoid function, which maps the log-SNR to the signal retention coefficient: αˉ=σ(0)=11+e0=12=0.5\bar{\alpha} = \sigma(0) = \frac{1}{1 + e^0} = \frac{1}{2} = 0.5.
  • Determine the Signal-to-Noise Ratio (SNR) by exponentiating the log-SNR: SNR=e0=1.0\text{SNR} = e^0 = 1.0.
  • Calculate the noise standard deviation σ\sigma based on the variance-preserving property, where the noise variance is 1−αˉ1 - \bar{\alpha}: σ=1−0.5=0.5≈0.70710678\sigma = \sqrt{1 - 0.5} = \sqrt{0.5} \approx 0.70710678.
  • Round each result to 6 decimal places to match the required output format: αˉ→0.5\bar{\alpha} \to 0.5, SNR→1.0\text{SNR} \to 1.0, and σ→0.707107\sigma \to 0.707107.
  • The final output is {'alpha_bar': 0.5, 'snr': 1.0, 'sigma': 0.707107}

Constraints:

  • lam is any real number.
  • alpha_bar = sigmoid(lam), snr = exp(lam), sigma = sqrt(1 - alpha_bar).
  • Round each to 6 decimals.
🔒

Editor locked

The code editor is locked for Pro problems. It is only available for free problems. Please upgrade to gain access to the code editor for all problems.

solution.py

Test Results

0/0
Run code to see test results.