#!/usr/bin/env python
# -*- coding: utf-8 -*-


from __future__ import print_function, division, absolute_import

import GPy
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
import sys
import fileinput
import subprocess
import numpy as np
import math
import pandas as pd
import scipy as sp
import scipy.stats
from bayes_opt import BayesianOptimization
from bayes_opt import UtilityFunction
from matplotlib import gridspec
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
from scipy.stats import norm
import safeopt
from sklearn import svm

# mu = [0,0,0]
# cov = [[1,0,0], [0,1,0],[0,0,1]]

mu = [0,0,0,0]
cov = [[1,0,0,0], [0,1,0,0],[0,0,1,0], [0,0,0,1]]
    
rv = sp.stats.multivariate_normal(mu,cov)

# result = rv.cdf([0, 0 ,0,  0])

X = np.linspace(-5,0,50)
Y = np.linspace(-5,0,50)
Z = np.linspace(-5,0,50)
W= np.linspace(-5,0,50)

dx = 0.1
dy = 0.1
dz = 0.1
dw = 0.1

i=0
j=0
k=0
p =0
iteration_countY = 0
iteration_countZ = 0
iteration_countW = 0
total_result = 0
iteration_number = 0
iteration_number2 = 0




# while True: ## 3D gauss test
#     total_result += 0.05*0.1*0.1*rv.pdf([X[i], Y[j], Z[k]])
#     i += 1
#     iteration_number += 1
#     if i==160:
#         i=0
#         iteration_countY += 1
#         if iteration_countY >= 1:
#             j += 1
#             if iteration_countY >= 160:
#                j = 0
#                # iteration_number2 += 1
#                iteration_countY = 0
#                iteration_countZ += 1
#                if iteration_countZ >= 1:
#                    k += 1
#     if iteration_countZ == 160:
#         break
                
while True: ## 4D gauss test

    total_result += dx*dy*dz*dw*rv.pdf([X[i], Y[j], Z[k], W[p]])
    i += 1
    iteration_number += 1
    if i==50:
        i=0
        iteration_countY += 1
        if iteration_countY >= 1:
            j += 1
            if iteration_countY >= 50:
                j = 0
                # iteration_number2 += 1
                iteration_countY = 0
                iteration_countZ += 1
                if iteration_countZ >= 1:
                    k += 1
                    if iteration_countZ >= 50:
                        k = 0
                        # iteration_number2 += 1
                        iteration_countZ = 0
                        iteration_countW += 1
                        if iteration_countW >= 1:
                            p += 1
                            print(" current p value is : ",p)
    if iteration_countW == 50:
        break
    
# print(result)
print(total_result)