File size: 922 Bytes
52fc221
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""Imported quadratic evidence/control result, independently implemented.

Source: TRUE MACHINE MEMORY RCCE and EDD Joint Reserve v2. This is NOT a
probability-of-repair model. It includes quadratic residual loss AND effort.
"""
import numpy as np


def recoverability(Sigma, explained, actuator, effort_price=1.):
    W = actuator @ actuator.T
    R = np.linalg.solve(W + effort_price*np.eye(len(W)), W)
    dividend = .5*np.trace(R @ explained)
    return {'dividend': float(dividend),
            'optimal_loss_plus_effort': float(.5*np.trace(Sigma)-dividend)}


def posterior(Sigma, O, noise):
    cross = Sigma @ O.T
    return Sigma - cross @ np.linalg.solve(O @ cross + noise, cross.T)


def reserve_birth(a, b):
    return (a**(1/3)+b**(1/3))**3


def joint_value(s, t, benefit, a=1., b=1.):
    return benefit*s/(1+s)*t/(1+t)-a*s-b*t


def reserve_cost(q, a=1., b=1.):
    return ((a+b)*q+2*np.sqrt(a*b*q))/(1-q)