[go: up one dir, main page]

File: loss.py

package info (click to toggle)
iminuit 2.30.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,660 kB
  • sloc: cpp: 14,591; python: 11,177; makefile: 11; sh: 5
file content (15 lines) | stat: -rw-r--r-- 335 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from matplotlib import pyplot as plt
import numpy as np


def soft_l1(z):
    return 2 * ((1 + z) ** 0.5 - 1)


x = np.linspace(-3, 3)
z = x**2
plt.plot(x, z, label="linear $\\rho(z) = z$")
plt.plot(x, soft_l1(z), label="soft L1-norm $\\rho(z) = 2(\\sqrt{1+z} - 1)$")
plt.xlabel("studentized residual")
plt.ylabel("cost")
plt.legend()