Giter VIP home page Giter VIP logo

logsumexp's Introduction

logsumexp

JavaScript implementation of logsumexp via (tabulated) softplus.

Abandoned as it is actually slower than just using Math.log and Math.exp. Oh well.

const lse = require('logsumexp')

for (let x = 0; x < 10; ++x)
  for (let y = 0; y < 20; ++y)
    console.log (x + " plus " + y + " is roughly " + Math.exp (lse.logsumexp (Math.log(x), Math.log(y))))

function benchmark() {
  let t0 = Date.now()
  for (let x = 0; x < 1000; ++x)
    for (let y = 0; y < 1000; ++y)
      lse.logsumexp (Math.log(x), Math.log(y))
  let t1 = Date.now()
  
  let t2 = Date.now()
  for (let x = 0; x < 1000; ++x)
    for (let y = 0; y < 1000; ++y)
      lse.slowLogsumexp (Math.log(x), Math.log(y))
  let t3 = Date.now()
  
  console.log ("With lookup: " + (t1 - t0) + "ms  Without lookup: " + (t3 - t2) + "ms")
}
benchmark()

logsumexp's People

Contributors

ihh avatar

Watchers

 avatar James Cloos avatar  avatar

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.