def LinearizedRockPhysicsModel(Phi, Clay, Sw, R):
    """
    LINEARIZED ROCK PHYSICS MODEL
    Linear rock physics model based on multilinear regression.
    Written by Dario Grana (August 2020)

    Parameters
    ----------
    Phi : float or array_like
        Porosity (unitless).
    Clay : float
        Clay volume (unitless).
    Sw : float
        Water saturation (unitless)
    R : float
        Regression coefficients matrix
        estimated with regress.m

    Returns
    -------
    Vp : float or array_like
        P-wave velocity (km/s).
    Vs : float or array_like
        S-wave velocity (km/s).
    Rho : float or array_like
        Density (g/cc).

    References: Grana, Mukerji, Doyen, 2021, Seismic Reservoir Modeling: Wiley - Chapter 2.1
    """

    # multilinear regression
    Vp = R[0, 0] * Phi + R[0, 1] * Clay + R[0, 2] * Sw + R[0, 3]
    Vs = R[1, 0] * Phi + R[1, 1] * Clay + R[1, 2] * Sw + R[1, 3]
    Rho = R[2, 0] * Phi + R[2, 1] * Clay + R[2, 2] * Sw + R[2, 3]
    
    return Vp, Vs, Rho