GithubHelp home page GithubHelp logo

Comments (1)

patrickbarks avatar patrickbarks commented on July 30, 2024

Few more issues:

Applies to dEntropy

1. The final calculation in dEntropy is:

abs(sum(lxmx * log(lxmx)) / sum(lxmx))

When lxmx == 0, the lxmx * log(lxmx) part yields NaN (i.e. 0 * -Inf). To get around this, instances of lxmx == 0 are first converted to 1. This trick works fine in the numerator, because the limit of x * log(x) as x approaches 0 is 0, and correspondingly 1 * log(1) == 0.

But the extra 1s added to lxmx are also getting carried into the denominator (R0 = sum(lxmx)), which is not correct. Suggest editing so that denominator is calculated before 0s are converted to 1s in lxmx.

2. There's a lot of code duplication in the final three blocks that calculate entropy with respect to the different types of reproduction: Fec, Clo, and FecClo. Suggest pulling the duplicated sections into a separate utility function that calculates entropy given vectors lx and fx (where fx is one of mx, cx, or mxcx).

Applies to kEntropy

3. When argument trapeze == TRUE, I think the kEntropy function currently implements the 'midpoint approximation' to a definite integral rather than the 'trapezoidal approximation', as advertised.

Some details on the two approximations below:
http://tutorial.math.lamar.edu/Classes/CalcII/ApproximatingDefIntegrals.aspx
https://www.r-bloggers.com/the-trapezoidal-rule-of-numerical-integration-in-r/

4. The kEntropy function returns NaN if any values of lx are 0 (due to the same log(0) issue described for dEntropy). Suggest adding code to omit late age-classes at/after which survivorship has fallen to 0.

from rage.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.