Git Product home page Git Product logo

Comments (2)

not522 avatar not522 commented on September 25, 2024 1

Thank you for your bug report! Your suggestion should work for a truncated Gaussian. I'll make a PR.

out = _norm_logpdf(x) - _log_gauss_mass(a, b) - np.log(scale)

In my understanding, this bug luckily does not affect the sampling results.

from optuna.

lerad avatar lerad commented on September 25, 2024

An easy way to reproduce the problem is by comparing the values to scipy.stats.truncnorm:

import numpy as np
from scipy.stats import truncnorm as scipy_truncnorm
from optuna.samplers._tpe import _truncnorm as optuna_truncnorm

print(f"scipy pdf(0, a=-10, b=10, scale=1): {np.exp(scipy_truncnorm.logpdf(0, a=-10, b=10, scale=1))}")
print(f"optuna pdf(0, a=-10, b=10, scale=1): {np.exp(optuna_truncnorm.logpdf(0, a=-10, b=10, scale=1))}")
print("---")
print(f"scipy pdf(0, a=-10, b=10, scale=2): {np.exp(scipy_truncnorm.logpdf(0, a=-10, b=10, scale=2))}")
print(f"optuna pdf(0, a=-10, b=10, scale=2): {np.exp(optuna_truncnorm.logpdf(0, a=-10, b=10, scale=2))}")

Output:

scipy pdf(0, a=-10, b=10, scale=1): 0.3989422804014327
optuna pdf(0, a=-10, b=10, scale=1): [0.39894228]
---
scipy pdf(0, a=-10, b=10, scale=2): 0.19947114020071632
optuna pdf(0, a=-10, b=10, scale=2): [0.39894228]

(According to the headers optuna's _truncnorm.py seems to originate from scipy. Maybe a bug that was fixed in an earlier version of scipy? I looked through the issues in scipy for truncnorm but could not find an issue which directly seems to relate to this problem.)

from optuna.

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.