Skip to content

ENH: Functions to calculate the average number of reflections and their density - #174

Open
mberz wants to merge 11 commits into
developfrom
enh/reflection_rate_and_number
Open

ENH: Functions to calculate the average number of reflections and their density#174
mberz wants to merge 11 commits into
developfrom
enh/reflection_rate_and_number

Conversation

@mberz

@mberz mberz commented Jul 8, 2026

Copy link
Copy Markdown
Member

Changes proposed in this pull request:

  • Add functions to calculate the average
    • reflection rate in a room based on diffuse field assumptions
    • total number of reflections in a diffuse field

The PR is partially inspired by pyfar/pyfar#782 by @ahms5, but implements the reflection density and total number of reflections separately from RIR synthesis.

@mberz mberz added the enhancement New feature or request label Jul 8, 2026
@mberz
mberz changed the base branch from main to develop July 8, 2026 16:01
@mberz
mberz requested a review from Copilot July 8, 2026 16:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds new parametric acoustics utilities to compute (under diffuse-field assumptions) the time-dependent average reflection density and the corresponding average cumulative number of reflections.

Changes:

  • Added average_reflection_density(...) to compute ( dN(t)/dt ) over time.
  • Added average_number_of_reflections(...) to compute ( N(t) ) over time.
  • Added unit tests covering nominal behavior and basic input-validation errors for both functions.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
pyrato/parametric.py Adds two new public parametric functions with docstrings and input validation.
tests/test_parametric.py Adds tests validating the new formulas and expected error conditions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pyrato/parametric.py
Comment thread pyrato/parametric.py
Comment thread tests/test_parametric.py
Comment on lines 6 to +9
import pyrato.parametric as parametric
from pyrato.parametric import mean_free_path
import pyrato as ra
import pyrato

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Importing as ra does not follow our conventions and should be replaced in the future.

Comment thread tests/test_parametric.py Outdated
mberz and others added 4 commits July 8, 2026 18:09
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@mberz mberz moved this from Backlog to Require review in Weekly Planning Jul 8, 2026
@mberz
mberz requested review from a team, ahms5, artur-pa, f-brinkmann, hoyer-a and sbch22 July 8, 2026 16:40
@mberz mberz self-assigned this Jul 8, 2026
@mberz mberz added this to the v1.1.0 milestone Jul 8, 2026
@mberz
mberz requested a review from h-chmeruk July 9, 2026 20:32

@hoyer-a hoyer-a left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, just some small comments on documentation

Comment thread pyrato/parametric.py Outdated
Comment thread pyrato/parametric.py Outdated
Comment thread pyrato/parametric.py Outdated
Comment thread pyrato/parametric.py Outdated
Comment thread pyrato/parametric.py Outdated
Comment thread pyrato/parametric.py Outdated
Comment thread pyrato/parametric.py
Comment thread pyrato/parametric.py
Comment thread pyrato/parametric.py
The average number of reflections is calculated as the following ratio [#]_

.. math::
N(t) = \frac{4 \pi c^3 t^3}{3 V},

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should mention that the average number of reflections is derived
from the average reflection density in our method:

.. math::
    N(t) = \frac{4 \pi c^3 t^3}{3V} =
    \frac{\mu(t)t}{3},

where :math:\mu(t) is the average reflection density obtained from `:func:`average_reflection_density.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say it's more the other way around (the density is the derivative of the total number). Anyhow, I'd not add this here.

Comment thread tests/test_parametric.py
@mberz
mberz requested review from artur-pa and hoyer-a August 11, 2026 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: Require review

Development

Successfully merging this pull request may close these issues.

4 participants