SDEprob.py
def plotSolutions(
        self, methodList=None, subplot=False,simNum = None, plotMean = False,
        plotSamp = True, plotTrue = True, plotTrueMean = False
    ):
        """Plots solututions specified by input or else assumes

        Most of the code performs checks on what to print. plotSamp specifies
        whether a sample path is printed, plotTrue indicates whether a true
        solution is printed. plotTruemean indicates whether a mean of true
        solutions is printed."""
        if self.totSimNum == 1:#Mean calculations unnecessary for 1 sample path
            plotMean = False#Drops plotting mean for single sample path.
            if simNum == None:
                simNum = 0#Sets first sample path if no simNum included.
        else:#Creates dictionary of means of solution.
            meanDict ={}
            if plotMean:
                if methodList == None:
                    for key, value in self.solDict.items():
                        meanDict[key] = np.mean(value.X,axis=2)
                else:
                    for key in methodList:
                        meanDict[key] = np.mean(solDict[key].X,axis=2)
        if plotTrueMean:
            trueMean = np.mean(self.trueX,axis=1)
        if plotSamp == True and simNum == None:
            simNum = 0

        #Plots solutions in methodList, else plots all solutions in solDict.
        if methodList == None:
            keys = self.solDict.keys()
        else:
            keys = methodList

        #Plots seperate figure for each dimension.
        for i in range(self.d):
            plt.figure(i)
            if plotSamp:#Plot sample path.
                for key in self.solDict.keys():
                    if key in keys:
                        value = self.solDict[key]
                        string = (key + ", sim = " + str(simNum)
                            +", dim = " + str(i)+", len(t) = " +
                            str(len(self.t)) + ".")
                        X = np.squeeze(value.X[:,i,simNum])#For when shape=(1,)
                        plt.plot(self.t,X,label=string)
            if plotTrue:#Plots true solution of sample path simNum
                string = ("True solution, sim = "+ str(simNum)
                    +", dim = " + str(i)+", len(tFine) = " +
                            str(len(self.tFine)) + ".")
                X = np.squeeze(self.trueX[:,i,simNum])#For when shape=(1,)
                plt.plot(self.tFine, X,label=string)
            if plotTrueMean:#Plots mean of true solution
                string = ("Mean of true solution, dim = " + str(i) + 
                    ", len(tFine) = " + str(len(self.tFine)) + ".")
                X = np.squeeze(self.trueMean[:,i])#For when shape=(1,)
                plt.plot(self.tFine, X,label=string)
            if plotMean:#Plot means in meanDict.
                for key, value in meanDict.items():
                    string = ("Mean of " + key +" along dimension nr. " 
                    + str(i) + ", len(t) = " + str(len(self.t)) + ".")
                    X = np.squeeze(value[:,i])#For when shape=(1,)
                    plt.plot(self.t,X,label=string)
            plt.xlabel('t')
            plt.ylabel('X(t)')
            plt.title('Plot of problem named '+self.name)
            plt.legend(loc='upper left')
        plt.show()
Plots solututions specified by input or else assumes

        Most of the code performs checks on what to print. plotSamp specifies
        whether a sample path is printed, plotTrue indicates whether a true
        solution is printed. plotTruemean indicates whether a mean of true
        solutions is printed.
Plots solututions specified by input or else assumes
Most of the code performs checks on what to print. plotSamp specifies
whether a sample path is printed, plotTrue indicates whether a true
solution is printed. plotTruemean indicates whether a mean of true
solutions is printed.
Plots solututions specified by input or else assumes Most of the code performs checks on what to print . plotSamp specifies whether a sample path is printed plotTrue indicates whether a true solution is printed . plotTruemean indicates whether a mean of true solutions is printed .
def plotSolutions(
        self, methodList=None, subplot=False,simNum = None, plotMean = False,
        plotSamp = True, plotTrue = True, plotTrueMean = False
    ):
        if self.totSimNum == 1:
            plotMean = False
            if simNum == None:
                simNum = 0
        else:
            meanDict ={}
            if plotMean:
                if methodList == None:
                    for key, value in self.solDict.items():
                        meanDict[key] = np.mean(value.X,axis=2)
                else:
                    for key in methodList:
                        meanDict[key] = np.mean(solDict[key].X,axis=2)
        if plotTrueMean:
            trueMean = np.mean(self.trueX,axis=1)
        if plotSamp == True and simNum == None:
            simNum = 0
        if methodList == None:
            keys = self.solDict.keys()
        else:
            keys = methodList
        for i in range(self.d):
            plt.figure(i)
            if plotSamp:
                for key in self.solDict.keys():
                    if key in keys:
                        value = self.solDict[key]
                        string = (key + ", sim = " + str(simNum)
                            +", dim = " + str(i)+", len(t) = " +
                            str(len(self.t)) + ".")
                        X = np.squeeze(value.X[:,i,simNum])
                        plt.plot(self.t,X,label=string)
            if plotTrue:
                string = ("True solution, sim = "+ str(simNum)
                    +", dim = " + str(i)+", len(tFine) = " +
                            str(len(self.tFine)) + ".")
                X = np.squeeze(self.trueX[:,i,simNum])
                plt.plot(self.tFine, X,label=string)
            if plotTrueMean:
                string = ("Mean of true solution, dim = " + str(i) + 
                    ", len(tFine) = " + str(len(self.tFine)) + ".")
                X = np.squeeze(self.trueMean[:,i])
                plt.plot(self.tFine, X,label=string)
            if plotMean:
                for key, value in meanDict.items():
                    string = ("Mean of " + key +" along dimension nr. " 
                    + str(i) + ", len(t) = " + str(len(self.t)) + ".")
                    X = np.squeeze(value[:,i])
                    plt.plot(self.t,X,label=string)
            plt.xlabel('t')
            plt.ylabel('X(t)')
            plt.title('Plot of problem named '+self.name)
            plt.legend(loc='upper left')
        plt.show()
def plotSolutions ( self , methodList = None , subplot = False , simNum = None , plotMean = False , plotSamp = True , plotTrue = True , plotTrueMean = False ) : if self . totSimNum == 1 : plotMean = False if simNum == None : simNum = 0 else : meanDict = { } if plotMean : if methodList == None : for key , value in self . solDict . items ( ) : meanDict [ key ] = np . mean ( value . X , axis = 2 ) else : for key in methodList : meanDict [ key ] = np . mean ( solDict [ key ] . X , axis = 2 ) if plotTrueMean : trueMean = np . mean ( self . trueX , axis = 1 ) if plotSamp == True and simNum == None : simNum = 0 if methodList == None : keys = self . solDict . keys ( ) else : keys = methodList for i in range ( self . d ) : plt . figure ( i ) if plotSamp : for key in self . solDict . keys ( ) : if key in keys : value = self . solDict [ key ] string = ( key + ", sim = " + str ( simNum ) + ", dim = " + str ( i ) + ", len(t) = " + str ( len ( self . t ) ) + "." ) X = np . squeeze ( value . X [ : , i , simNum ] ) plt . plot ( self . t , X , label = string ) if plotTrue : string = ( "True solution, sim = " + str ( simNum ) + ", dim = " + str ( i ) + ", len(tFine) = " + str ( len ( self . tFine ) ) + "." ) X = np . squeeze ( self . trueX [ : , i , simNum ] ) plt . plot ( self . tFine , X , label = string ) if plotTrueMean : string = ( "Mean of true solution, dim = " + str ( i ) + ", len(tFine) = " + str ( len ( self . tFine ) ) + "." ) X = np . squeeze ( self . trueMean [ : , i ] ) plt . plot ( self . tFine , X , label = string ) if plotMean : for key , value in meanDict . items ( ) : string = ( "Mean of " + key + " along dimension nr. " + str ( i ) + ", len(t) = " + str ( len ( self . t ) ) + "." ) X = np . squeeze ( value [ : , i ] ) plt . plot ( self . t , X , label = string ) plt . xlabel ( 't' ) plt . ylabel ( 'X(t)' ) plt . title ( 'Plot of problem named ' + self . name ) plt . legend ( loc = 'upper left' ) plt . show ( )
Plots solututions specified by input or else assumes
Most of the code performs checks on what to print.
Plots solututions specified by input or else assumes Most of the code performs checks on what to print .
"""Plots solututions specified by input or else assumes

        Most of the code performs checks on what to print. plotSamp specifies
        whether a sample path is printed, plotTrue indicates whether a true
        solution is printed. plotTruemean indicates whether a mean of true
        solutions is printed.""" #Mean calculations unnecessary for 1 sample path
 #Drops plotting mean for single sample path.
 #Sets first sample path if no simNum included.
 #Creates dictionary of means of solution.
 #Plots solutions in methodList, else plots all solutions in solDict.
 #Plots seperate figure for each dimension.
 #Plot sample path.
 #For when shape=(1,)
 #Plots true solution of sample path simNum
 #For when shape=(1,)
 #Plots mean of true solution
 #For when shape=(1,)
 #Plot means in meanDict.
 #For when shape=(1,)

self
methodList
subplot
simNum
plotMean
plotSamp
plotTrue
plotTrueMean