func (self *base) Backward(z []float64) []float64 { nu, nz := self.nu, self.nz lower, upper := self.lower, self.upper ω := append([]float64(nil), lower...) n := make([]float64, nz) // Independent uniform to independent Gaussian for i := range n { n[i] = standardGaussian.Invert(z[i]) } // Independent Gaussian to dependent Gaussian u := infinity.Linear(self.copula.C, n, nu, nz) // Dependent Gaussian to dependent uniform for i := range u { u[i] = standardGaussian.Cumulate(u[i]) } // Dependent uniform to dependent desired for i, tid := range self.tasks { ω[tid] += (upper[tid] - lower[tid]) * self.marginals[i].Invert(u[i]) } return ω }
func (self *base) Forward(ω []float64) []float64 { nu, nz := self.nu, self.nz lower, upper := self.lower, self.upper z := make([]float64, nz) u := make([]float64, nu) // Dependent desired to dependent uniform for i, tid := range self.tasks { ω := (ω[tid] - lower[tid]) / (upper[tid] - lower[tid]) u[i] = self.marginals[i].Cumulate(ω) } // Dependent uniform to dependent Gaussian for i := range u { u[i] = standardGaussian.Invert(u[i]) } // Dependent Gaussian to independent Gaussian n := infinity.Linear(self.copula.D, u, nz, nu) // Independent Gaussian to independent uniform for i := range n { z[i] = standardGaussian.Cumulate(n[i]) } return z }