Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
Generate 2D Gaussian Blur Kernels
00:00
5 left

Generate 2D Gaussian Blur Kernels

EasyPython

Problem

Luma AI image pipelines use Gaussian blur kernels to smooth rendered frames before downstream processing. Implement gaussian_kernel(k, sigma) to return a normalized two-dimensional Gaussian kernel of size k x k.

Formal Specification

Given an odd positive integer k and a positive floating-point standard deviation sigma, center the kernel at coordinate (0, 0). For each offset (x, y), compute:

G(x, y) = exp(-(x² + y²) / (2 * sigma²))

Normalize every value by the sum of all unnormalized values so that the returned matrix sums to 1.0. Coordinates should range from -(k // 2) through k // 2 in both dimensions. Return a Python list containing k lists, each with k floats. Values are judged with a tolerance of 1e-9.

Constraints

  • 1 <= k <= 101
  • k is odd
  • 0 < sigma <= 100.0
  • Return exactly k rows, each containing k floating-point values
  • The sum of all returned values must be within 1e-9 of 1.0

Function Signature

def gaussian_kernel(k, sigma):
Interviewer

Your question is Generate 2D Gaussian Blur Kernels. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePython 3
Sign up free to run your codeLog inLn 2
Run your code to see test output here.