{"nwo":"CamDavidsonPilon\/PyProcess","sha":"382da02d0f9732d75624538effa11caded161779","path":"pyprocess\/pyprocess.py","language":"python","identifier":"transform_path","parameters":"(path,f)","argument_list":"","return_statement":"return [(p[0],f(p[1])) for p in path]","docstring":"accepts a path, ie [(t,x_t)], and transforms it into [(t,f(x)].","docstring_summary":"accepts a path, ie [(t,x_t)], and transforms it into [(t,f(x)].","docstring_tokens":["accepts","a","path","ie","[","(","t","x_t",")","]","and","transforms","it","into","[","(","t","f","(","x",")","]","."],"function":"def transform_path(path,f):\n \"accepts a path, ie [(t,x_t)], and transforms it into [(t,f(x)].\"\n return [(p[0],f(p[1])) for p in path]","function_tokens":["def","transform_path","(","path",",","f",")",":","return","[","(","p","[","0","]",",","f","(","p","[","1","]",")",")","for","p","in","path","]"],"url":"https:\/\/github.com\/CamDavidsonPilon\/PyProcess\/blob\/382da02d0f9732d75624538effa11caded161779\/pyprocess\/pyprocess.py#L1937-L1939"} {"nwo":"CamDavidsonPilon\/PyProcess","sha":"382da02d0f9732d75624538effa11caded161779","path":"pyprocess\/pyprocess.py","language":"python","identifier":"Step_process._mean_number_of_jumps","parameters":"(self,t, n_simulations = 10000)","argument_list":"","return_statement":"return sum\/n_simulations","docstring":"This needs to solve the following:\n E[ min(N) | T_1 + T_2 + .. T_N >= t ]\n <=>\n E[ N | T_1 + T_2 + .. T_{N-1} < t, T_1 + T_2 + .. T_N >= t ]\n where we can sample T only.","docstring_summary":"This needs to solve the following:\n E[ min(N) | T_1 + T_2 + .. T_N >= t ]\n <=>\n E[ N | T_1 + T_2 + .. T_{N-1} < t, T_1 + T_2 + .. T_N >= t ]\n where we can sample T only.","docstring_tokens":["This","needs","to","solve","the","following",":","E","[","min","(","N",")","|","T_1","+","T_2","+","..","T_N",">","=","t","]","<","=",">","E","[","N","|","T_1","+","T_2","+","..","T_","{","N","-","1","}","<","t","T_1","+","T_2","+","..","T_N",">","=","t","]","where","we","can","sample","T","only","."],"function":"def _mean_number_of_jumps(self,t, n_simulations = 10000):\n self._check_time(t)\n \"\"\"\n This needs to solve the following:\n E[ min(N) | T_1 + T_2 + .. T_N >= t ]\n <=>\n E[ N | T_1 + T_2 + .. T_{N-1} < t, T_1 + T_2 + .. T_N >= t ]\n where we can sample T only. \n \n \"\"\"\n warnings.warn(\"Attn: performing MC simulation. %d simulations.\"%n_simulations)\n v = np.zeros( n_simulations )\n continue_ = True\n i = 1\n t = t - self.startTime #should be positive.\n size = v.shape[0]\n sum = 0\n sum_sq = 0\n while continue_:\n v += self.T.rvs( size )\n #count how many are greater than t\n n_greater_than_t = (v>=t).sum()\n sum += n_greater_than_t*i \n \n v = v[v < t]\n i+=1\n size = v.shape[0]\n empty = size == 0\n \n \n if empty:\n continue_ = False\n \n if i > 10000:\n warnings.warn(\"The algorithm did not converge. Be sure 'T' is a non negative random \\\n variable, or set 't' lower.\")\n break\n\n return sum\/n_simulations","function_tokens":["def","_mean_number_of_jumps","(","self",",","t",",","n_simulations","=","10000",")",":","self",".","_check_time","(","t",")","warnings",".","warn","(","\"Attn: performing MC simulation. %d simulations.\"","%","n_simulations",")","v","=","np",".","zeros","(","n_simulations",")","continue_","=","True","i","=","1","t","=","t","-","self",".","startTime","#should be positive.","size","=","v",".","shape","[","0","]","sum","=","0","sum_sq","=","0","while","continue_",":","v","+=","self",".","T",".","rvs","(","size",")","#count how many are greater than t","n_greater_than_t","=","(","v",">=","t",")",".","sum","(",")","sum","+=","n_greater_than_t","*","i","v","=","v","[","v","<","t","]","i","+=","1","size","=","v",".","shape","[","0","]","empty","=","size","==","0","if","empty",":","continue_","=","False","if","i",">","10000",":","warnings",".","warn","(","\"The algorithm did not converge. Be sure 'T' is a non negative random \\\n variable, or set 't' lower.\"",")","break","return","sum","\/","n_simulations"],"url":"https:\/\/github.com\/CamDavidsonPilon\/PyProcess\/blob\/382da02d0f9732d75624538effa11caded161779\/pyprocess\/pyprocess.py#L79-L117"} {"nwo":"CamDavidsonPilon\/PyProcess","sha":"382da02d0f9732d75624538effa11caded161779","path":"pyprocess\/pyprocess.py","language":"python","identifier":"Renewal_process.forward_recurrence_time_pdf","parameters":"(self,x)","argument_list":"","return_statement":"return self.renewal_rate*self.T.sf(x)","docstring":"the forward recurrence time RV is the time need to wait till the next event, after arriving to the system at a large future time","docstring_summary":"the forward recurrence time RV is the time need to wait till the next event, after arriving to the system at a large future time","docstring_tokens":["the","forward","recurrence","time","RV","is","the","time","need","to","wait","till","the","next","event","after","arriving","to","the","system","at","a","large","future","time"],"function":"def forward_recurrence_time_pdf(self,x):\n \"the forward recurrence time RV is the time need to wait till the next event, after arriving to the system at a large future time\"\n return self.renewal_rate*self.T.sf(x)","function_tokens":["def","forward_recurrence_time_pdf","(","self",",","x",")",":","return","self",".","renewal_rate","*","self",".","T",".","sf","(","x",")"],"url":"https:\/\/github.com\/CamDavidsonPilon\/PyProcess\/blob\/382da02d0f9732d75624538effa11caded161779\/pyprocess\/pyprocess.py#L178-L180"} {"nwo":"CamDavidsonPilon\/PyProcess","sha":"382da02d0f9732d75624538effa11caded161779","path":"pyprocess\/pyprocess.py","language":"python","identifier":"Renewal_process.backwards_recurrence_time_pdf","parameters":"(self,x)","argument_list":"","return_statement":"return self.forward_recurrence_time_pdf(x)","docstring":"the backwards recurrence time is the time since the last event after arriving to the system at a large future time","docstring_summary":"the backwards recurrence time is the time since the last event after arriving to the system at a large future time","docstring_tokens":["the","backwards","recurrence","time","is","the","time","since","the","last","event","after","arriving","to","the","system","at","a","large","future","time"],"function":"def backwards_recurrence_time_pdf(self,x):\n \"the backwards recurrence time is the time since the last event after arriving to the system at a large future time\"\n return self.forward_recurrence_time_pdf(x)","function_tokens":["def","backwards_recurrence_time_pdf","(","self",",","x",")",":","return","self",".","forward_recurrence_time_pdf","(","x",")"],"url":"https:\/\/github.com\/CamDavidsonPilon\/PyProcess\/blob\/382da02d0f9732d75624538effa11caded161779\/pyprocess\/pyprocess.py#L182-L184"} {"nwo":"CamDavidsonPilon\/PyProcess","sha":"382da02d0f9732d75624538effa11caded161779","path":"pyprocess\/pyprocess.py","language":"python","identifier":"Renewal_process.forward_recurrence_time_cdf","parameters":"(self,x)","argument_list":"","return_statement":"return int.quad(self.forward_recurrence_time_pdf, 0, x)","docstring":"the forward recurrence time RV is the time need to wait till the next event, after arriving to the system at a large future time","docstring_summary":"the forward recurrence time RV is the time need to wait till the next event, after arriving to the system at a large future time","docstring_tokens":["the","forward","recurrence","time","RV","is","the","time","need","to","wait","till","the","next","event","after","arriving","to","the","system","at","a","large","future","time"],"function":"def forward_recurrence_time_cdf(self,x):\n \"the forward recurrence time RV is the time need to wait till the next event, after arriving to the system at a large future time\"\n return int.quad(self.forward_recurrence_time_pdf, 0, x)","function_tokens":["def","forward_recurrence_time_cdf","(","self",",","x",")",":","return","int",".","quad","(","self",".","forward_recurrence_time_pdf",",","0",",","x",")"],"url":"https:\/\/github.com\/CamDavidsonPilon\/PyProcess\/blob\/382da02d0f9732d75624538effa11caded161779\/pyprocess\/pyprocess.py#L186-L188"} {"nwo":"CamDavidsonPilon\/PyProcess","sha":"382da02d0f9732d75624538effa11caded161779","path":"pyprocess\/pyprocess.py","language":"python","identifier":"Renewal_process.backward_recurrence_time_cdf","parameters":"(self,x)","argument_list":"","return_statement":"return int.quad(self.forward_recurrence_time_pdf, 0, x)","docstring":"the backwards recurrence time is the time since the last event after arriving to the system at a large future time","docstring_summary":"the backwards recurrence time is the time since the last event after arriving to the system at a large future time","docstring_tokens":["the","backwards","recurrence","time","is","the","time","since","the","last","event","after","arriving","to","the","system","at","a","large","future","time"],"function":"def backward_recurrence_time_cdf(self,x):\n \"the backwards recurrence time is the time since the last event after arriving to the system at a large future time\"\n return int.quad(self.forward_recurrence_time_pdf, 0, x)","function_tokens":["def","backward_recurrence_time_cdf","(","self",",","x",")",":","return","int",".","quad","(","self",".","forward_recurrence_time_pdf",",","0",",","x",")"],"url":"https:\/\/github.com\/CamDavidsonPilon\/PyProcess\/blob\/382da02d0f9732d75624538effa11caded161779\/pyprocess\/pyprocess.py#L190-L192"} {"nwo":"CamDavidsonPilon\/PyProcess","sha":"382da02d0f9732d75624538effa11caded161779","path":"pyprocess\/pyprocess.py","language":"python","identifier":"Renewal_process.spread_pdf","parameters":"(self,x)","argument_list":"","return_statement":"","docstring":"the RV distributed according to the spread_pdf is the (random) length of time between the previous and next event\/jump\n when you arrive at a large future time.","docstring_summary":"the RV distributed according to the spread_pdf is the (random) length of time between the previous and next event\/jump\n when you arrive at a large future time.","docstring_tokens":["the","RV","distributed","according","to","the","spread_pdf","is","the","(","random",")","length","of","time","between","the","previous","and","next","event","\/","jump","when","you","arrive","at","a","large","future","time","."],"function":"def spread_pdf(self,x):\n \"\"\"the RV distributed according to the spread_pdf is the (random) length of time between the previous and next event\/jump\n when you arrive at a large future time.\"\"\"\n try:\n return self.renewal_rate*x*self.T.pdf(x)\n except AttributeError:\n return self.renewal_rate*x*self.T.pmf(x)","function_tokens":["def","spread_pdf","(","self",",","x",")",":","try",":","return","self",".","renewal_rate","*","x","*","self",".","T",".","pdf","(","x",")","except","AttributeError",":","return","self",".","renewal_rate","*","x","*","self",".","T",".","pmf","(","x",")"],"url":"https:\/\/github.com\/CamDavidsonPilon\/PyProcess\/blob\/382da02d0f9732d75624538effa11caded161779\/pyprocess\/pyprocess.py#L194-L200"} {"nwo":"CamDavidsonPilon\/PyProcess","sha":"382da02d0f9732d75624538effa11caded161779","path":"pyprocess\/pyprocess.py","language":"python","identifier":"Renewal_process._sample_path","parameters":"(self,time, N =1)","argument_list":"","return_statement":"","docstring":"parameters: \n time: an interable that returns floats OR if a single float, returns (path,jumps) up to time t.\n N: the number of paths to return. negative N returns an iterator of size N.\n returns:\n path: the sample path at the times in times\n jumps: the times when the process jumps\n \n Scales linearly with number of sequences and time.","docstring_summary":"parameters: \n time: an interable that returns floats OR if a single float, returns (path,jumps) up to time t.\n N: the number of paths to return. negative N returns an iterator of size N.\n returns:\n path: the sample path at the times in times\n jumps: the times when the process jumps\n \n Scales linearly with number of sequences and time.","docstring_tokens":["parameters",":","time",":","an","interable","that","returns","floats","OR","if","a","single","float","returns","(","path","jumps",")","up","to","time","t",".","N",":","the","number","of","paths","to","return",".","negative","N","returns","an","iterator","of","size","N",".","returns",":","path",":","the","sample","path","at","the","times","in","times","jumps",":","the","times","when","the","process","jumps","Scales","linearly","with","number","of","sequences","and","time","."],"function":"def _sample_path(self,time, N =1):\n \"\"\"\n parameters: \n time: an interable that returns floats OR if a single float, returns (path,jumps) up to time t.\n N: the number of paths to return. negative N returns an iterator of size N.\n returns:\n path: the sample path at the times in times\n jumps: the times when the process jumps\n \n Scales linearly with number of sequences and time.\n \n \"\"\"\n if N < 0:\n return self._iterator_sample_paths(time, -N)\n \n else:\n return self.__sample_path( time, N )","function_tokens":["def","_sample_path","(","self",",","time",",","N","=","1",")",":","if","N","<","0",":","return","self",".","_iterator_sample_paths","(","time",",","-","N",")","else",":","return","self",".","__sample_path","(","time",",","N",")"],"url":"https:\/\/github.com\/CamDavidsonPilon\/PyProcess\/blob\/382da02d0f9732d75624538effa11caded161779\/pyprocess\/pyprocess.py#L202-L218"} {"nwo":"CamDavidsonPilon\/PyProcess","sha":"382da02d0f9732d75624538effa11caded161779","path":"pyprocess\/pyprocess.py","language":"python","identifier":"Renewal_process._sample_jumps","parameters":"(self,t, N=1)","argument_list":"","return_statement":"","docstring":"Generate N simulations of jump times prior to some time t > startTime.\n \n parameters:\n t: the end of the processes. \n N: the number of samples to return, -N to return a generator of size N\n returns:\n An irregular numpy array, with first dimension N, and each element an np.array \n with random length.\n \n example:\n >> print renewal_ps.generate_sample_jumps( 1, N=2)\n np.array( [ [2,2.5,3.0], [1.0,2.0] ], dtype=0bject )","docstring_summary":"Generate N simulations of jump times prior to some time t > startTime.\n \n parameters:\n t: the end of the processes. \n N: the number of samples to return, -N to return a generator of size N\n returns:\n An irregular numpy array, with first dimension N, and each element an np.array \n with random length.\n \n example:\n >> print renewal_ps.generate_sample_jumps( 1, N=2)\n np.array( [ [2,2.5,3.0], [1.0,2.0] ], dtype=0bject )","docstring_tokens":["Generate","N","simulations","of","jump","times","prior","to","some","time","t",">","startTime",".","parameters",":","t",":","the","end","of","the","processes",".","N",":","the","number","of","samples","to","return","-","N","to","return","a","generator","of","size","N","returns",":","An","irregular","numpy","array","with","first","dimension","N","and","each","element","an","np",".","array","with","random","length",".","example",":",">>","print","renewal_ps",".","generate_sample_jumps","(","1","N","=","2",")","np",".","array","(","[","[","2","2",".","5","3",".","0","]","[","1",".","0","2",".","0","]","]","dtype","=","0bject",")"],"function":"def _sample_jumps(self,t, N=1):\n \"\"\" \n Generate N simulations of jump times prior to some time t > startTime.\n \n parameters:\n t: the end of the processes. \n N: the number of samples to return, -N to return a generator of size N\n returns:\n An irregular numpy array, with first dimension N, and each element an np.array \n with random length.\n \n example:\n >> print renewal_ps.generate_sample_jumps( 1, N=2)\n np.array( [ [2,2.5,3.0], [1.0,2.0] ], dtype=0bject )\n \n \"\"\"\n if N<0:\n return ( self.__sample_jumps(t) for i in xrange(-N) )\n else:\n return np.asarray( [ self.__sample_jumps(t) for i in xrange(N) ] )","function_tokens":["def","_sample_jumps","(","self",",","t",",","N","=","1",")",":","if","N","<","0",":","return","(","self",".","__sample_jumps","(","t",")","for","i","in","xrange","(","-","N",")",")","else",":","return","np",".","asarray","(","[","self",".","__sample_jumps","(","t",")","for","i","in","xrange","(","N",")","]",")"],"url":"https:\/\/github.com\/CamDavidsonPilon\/PyProcess\/blob\/382da02d0f9732d75624538effa11caded161779\/pyprocess\/pyprocess.py#L266-L285"} {"nwo":"CamDavidsonPilon\/PyProcess","sha":"382da02d0f9732d75624538effa11caded161779","path":"pyprocess\/pyprocess.py","language":"python","identifier":"Renewal_process._sample_position","parameters":"(self,t, N = 1)","argument_list":"","return_statement":"return x","docstring":"Generate the position of the process at time t > startTime\n parameters:\n N: number of samples\n t: position to sample at.\n returns:\n returns a (n,) np.array","docstring_summary":"Generate the position of the process at time t > startTime\n parameters:\n N: number of samples\n t: position to sample at.\n returns:\n returns a (n,) np.array","docstring_tokens":["Generate","the","position","of","the","process","at","time","t",">","startTime","parameters",":","N",":","number","of","samples","t",":","position","to","sample","at",".","returns",":","returns","a","(","n",")","np",".","array"],"function":"def _sample_position(self,t, N = 1):\n \"\"\"\n Generate the position of the process at time t > startTime\n parameters:\n N: number of samples\n t: position to sample at.\n returns:\n returns a (n,) np.array \n \"\"\"\n v = np.zeros( N ) \n iv = np.ones( N, dtype=bool )\n x = self.startPosition*np.ones( N) \n continue_ = True\n i = 1\n t = t - self.startTime #should be positive.\n size = v.shape[0]\n while continue_:\n n_samples = iv.sum()\n v[iv] += self.T.rvs( n_samples )\n \n #if the next time is beyond reach, we do not add a new jump\n iv[ v >= t] = False\n n_samples = iv.sum()\n\n x[iv] += self.J.rvs( n_samples )\n\n size = iv.sum() #any left?\n empty = size == 0\n \n i+=1\n if empty:\n continue_ = False\n \n if i > 10000:\n warnings.warn(\"The algorithm did not converge. Be sure 'T' is a non negative random \\\n variable, or set 't' to a smaller value.\")\n break\n \n return x","function_tokens":["def","_sample_position","(","self",",","t",",","N","=","1",")",":","v","=","np",".","zeros","(","N",")","iv","=","np",".","ones","(","N",",","dtype","=","bool",")","x","=","self",".","startPosition","*","np",".","ones","(","N",")","continue_","=","True","i","=","1","t","=","t","-","self",".","startTime","#should be positive.","size","=","v",".","shape","[","0","]","while","continue_",":","n_samples","=","iv",".","sum","(",")","v","[","iv","]","+=","self",".","T",".","rvs","(","n_samples",")","#if the next time is beyond reach, we do not add a new jump","iv","[","v",">=","t","]","=","False","n_samples","=","iv",".","sum","(",")","x","[","iv","]","+=","self",".","J",".","rvs","(","n_samples",")","size","=","iv",".","sum","(",")","#any left?","empty","=","size","==","0","i","+=","1","if","empty",":","continue_","=","False","if","i",">","10000",":","warnings",".","warn","(","\"The algorithm did not converge. Be sure 'T' is a non negative random \\\n variable, or set 't' to a smaller value.\"",")","break","return","x"],"url":"https:\/\/github.com\/CamDavidsonPilon\/PyProcess\/blob\/382da02d0f9732d75624538effa11caded161779\/pyprocess\/pyprocess.py#L297-L335"} {"nwo":"CamDavidsonPilon\/PyProcess","sha":"382da02d0f9732d75624538effa11caded161779","path":"pyprocess\/pyprocess.py","language":"python","identifier":"Poisson_process._mean","parameters":"(self,t)","argument_list":"","return_statement":"","docstring":"recall that a conditional poisson process N_t | N_T=n ~ Bin(n, t\/T)","docstring_summary":"recall that a conditional poisson process N_t | N_T=n ~ Bin(n, t\/T)","docstring_tokens":["recall","that","a","conditional","poisson","process","N_t","|","N_T","=","n","~","Bin","(","n","t","\/","T",")"],"function":"def _mean(self,t):\n \"\"\"\n recall that a conditional poisson process N_t | N_T=n ~ Bin(n, t\/T)\n \"\"\"\n if not self.conditional: \n return self.startPosition + self.rate*(t-self.startTime)\n else:\n return self.endPosition*float(t)\/self.endTime","function_tokens":["def","_mean","(","self",",","t",")",":","if","not","self",".","conditional",":","return","self",".","startPosition","+","self",".","rate","*","(","t","-","self",".","startTime",")","else",":","return","self",".","endPosition","*","float","(","t",")","\/","self",".","endTime"],"url":"https:\/\/github.com\/CamDavidsonPilon\/PyProcess\/blob\/382da02d0f9732d75624538effa11caded161779\/pyprocess\/pyprocess.py#L376-L383"} {"nwo":"CamDavidsonPilon\/PyProcess","sha":"382da02d0f9732d75624538effa11caded161779","path":"pyprocess\/pyprocess.py","language":"python","identifier":"Poisson_process._var","parameters":"(self,t)","argument_list":"","return_statement":"","docstring":"parameters:\n t: a time > startTime (and less than endTime if present).\n returns:\n a float.\n \n recall that a conditional poisson process N_t | N_T=n ~ Bin(n, t\/T)","docstring_summary":"parameters:\n t: a time > startTime (and less than endTime if present).\n returns:\n a float.\n \n recall that a conditional poisson process N_t | N_T=n ~ Bin(n, t\/T)","docstring_tokens":["parameters",":","t",":","a","time",">","startTime","(","and","less","than","endTime","if","present",")",".","returns",":","a","float",".","recall","that","a","conditional","poisson","process","N_t","|","N_T","=","n","~","Bin","(","n","t","\/","T",")"],"function":"def _var(self,t):\n \"\"\"\n parameters:\n t: a time > startTime (and less than endTime if present).\n returns:\n a float.\n \n recall that a conditional poisson process N_t | N_T=n ~ Bin(n, t\/T)\n \n \"\"\"\n if self.conditional:\n return self.endPosition*(1-float(t)\/self.endTime)*float(t)\/self.endTime\n else:\n return self.rate*(t-self.startTime)","function_tokens":["def","_var","(","self",",","t",")",":","if","self",".","conditional",":","return","self",".","endPosition","*","(","1","-","float","(","t",")","\/","self",".","endTime",")","*","float","(","t",")","\/","self",".","endTime","else",":","return","self",".","rate","*","(","t","-","self",".","startTime",")"],"url":"https:\/\/github.com\/CamDavidsonPilon\/PyProcess\/blob\/382da02d0f9732d75624538effa11caded161779\/pyprocess\/pyprocess.py#L385-L398"} {"nwo":"CamDavidsonPilon\/PyProcess","sha":"382da02d0f9732d75624538effa11caded161779","path":"pyprocess\/pyprocess.py","language":"python","identifier":"Poisson_process._sample_jumps","parameters":"(self, t, N=1)","argument_list":"","return_statement":"","docstring":"Probably to be deleted.\n T: a float\n N: the number of sample paths\n Returns:\n an (N,) np.array of jump times.","docstring_summary":"Probably to be deleted.\n T: a float\n N: the number of sample paths\n Returns:\n an (N,) np.array of jump times.","docstring_tokens":["Probably","to","be","deleted",".","T",":","a","float","N",":","the","number","of","sample","paths","Returns",":","an","(","N",")","np",".","array","of","jump","times","."],"function":"def _sample_jumps(self, t, N=1):\n \"\"\"\n Probably to be deleted.\n T: a float\n N: the number of sample paths\n Returns:\n an (N,) np.array of jump times. \n \"\"\"\n if N<0:\n return ( self.__sample_jumps(t) for i in xrange(-N) )\n else:\n return np.asarray( [self.__sample_jumps(t) for i in xrange(N)] )","function_tokens":["def","_sample_jumps","(","self",",","t",",","N","=","1",")",":","if","N","<","0",":","return","(","self",".","__sample_jumps","(","t",")","for","i","in","xrange","(","-","N",")",")","else",":","return","np",".","asarray","(","[","self",".","__sample_jumps","(","t",")","for","i","in","xrange","(","N",")","]",")"],"url":"https:\/\/github.com\/CamDavidsonPilon\/PyProcess\/blob\/382da02d0f9732d75624538effa11caded161779\/pyprocess\/pyprocess.py#L416-L427"} {"nwo":"CamDavidsonPilon\/PyProcess","sha":"382da02d0f9732d75624538effa11caded161779","path":"pyprocess\/pyprocess.py","language":"python","identifier":"Diffusion_process.transition_pdf","parameters":"(self,t,y)","argument_list":"","return_statement":"","docstring":"this method calls self._transition_pdf(x,t,y) in the subclass","docstring_summary":"this method calls self._transition_pdf(x,t,y) in the subclass","docstring_tokens":["this","method","calls","self",".","_transition_pdf","(","x","t","y",")","in","the","subclass"],"function":"def transition_pdf(self,t,y):\n self._check_time(t)\n \"this method calls self._transition_pdf(x,t,y) in the subclass\"\n try:\n if not self.conditional:\n return self._transition_pdf(self.startPosition, t-self.startTime, y)\n else:\n return self._transition_pdf(self.startPosition, t-self.startTime, y)*self._transition_pdf(y, self.endTime-t, self.endPosition)\\\n \/self._transition_pdf(self.startPosition,self.endTime - self.startTime, self.endPosition)\n except AttributeError:\n raise AttributeError(\"Attn: transition density for process is not defined.\")","function_tokens":["def","transition_pdf","(","self",",","t",",","y",")",":","self",".","_check_time","(","t",")","try",":","if","not","self",".","conditional",":","return","self",".","_transition_pdf","(","self",".","startPosition",",","t","-","self",".","startTime",",","y",")","else",":","return","self",".","_transition_pdf","(","self",".","startPosition",",","t","-","self",".","startTime",",","y",")","*","self",".","_transition_pdf","(","y",",","self",".","endTime","-","t",",","self",".","endPosition",")","\/","self",".","_transition_pdf","(","self",".","startPosition",",","self",".","endTime","-","self",".","startTime",",","self",".","endPosition",")","except","AttributeError",":","raise","AttributeError","(","\"Attn: transition density for process is not defined.\"",")"],"url":"https:\/\/github.com\/CamDavidsonPilon\/PyProcess\/blob\/382da02d0f9732d75624538effa11caded161779\/pyprocess\/pyprocess.py#L542-L552"} {"nwo":"CamDavidsonPilon\/PyProcess","sha":"382da02d0f9732d75624538effa11caded161779","path":"pyprocess\/pyprocess.py","language":"python","identifier":"Diffusion_process.expected_value","parameters":"(self,t, f= lambda x:x, N=1e6)","argument_list":"","return_statement":"","docstring":"This function calculates the expected value of E[ X_t | F ] where F includes start conditions and possibly end conditions.","docstring_summary":"This function calculates the expected value of E[ X_t | F ] where F includes start conditions and possibly end conditions.","docstring_tokens":["This","function","calculates","the","expected","value","of","E","[","X_t","|","F","]","where","F","includes","start","conditions","and","possibly","end","conditions","."],"function":"def expected_value(self,t, f= lambda x:x, N=1e6):\n \"\"\"\n This function calculates the expected value of E[ X_t | F ] where F includes start conditions and possibly end conditions.\n \n \n \"\"\"\n warnings.warn( \"Performing Monte Carlo with %d simulations.\"%N)\n self._check_time(t)\n if not self.conditional:\n return f( self.sample_position(t, N) ).mean() \n else:\n #This uses a change of measure technique.\n \"\"\"\n sum=0\n self.conditional=False\n for i in range(N):\n X = self.generate_position_at(t)\n sum+=self._transition_pdf(X,self.endTime-t,self.endPosition)*f(X)\n self.conditional=True\n \"\"\"\n x = self.sample_position(t, N)\n mean = (self._transition_pdf(x,self.endTime-t,self.endPosition)*f(x)).mean()\n return mean\/self._transition_pdf(self.startPosition, self.endTime-self.startTime, self.endPosition)","function_tokens":["def","expected_value","(","self",",","t",",","f","=","lambda","x",":","x",",","N","=","1e6",")",":","warnings",".","warn","(","\"Performing Monte Carlo with %d simulations.\"","%","N",")","self",".","_check_time","(","t",")","if","not","self",".","conditional",":","return","f","(","self",".","sample_position","(","t",",","N",")",")",".","mean","(",")","else",":","#This uses a change of measure technique.","\"\"\"\n sum=0\n self.conditional=False\n for i in range(N):\n X = self.generate_position_at(t)\n sum+=self._transition_pdf(X,self.endTime-t,self.endPosition)*f(X)\n self.conditional=True\n \"\"\"","x","=","self",".","sample_position","(","t",",","N",")","mean","=","(","self",".","_transition_pdf","(","x",",","self",".","endTime","-","t",",","self",".","endPosition",")","*","f","(","x",")",")",".","mean","(",")","return","mean","\/","self",".","_transition_pdf","(","self",".","startPosition",",","self",".","endTime","-","self",".","startTime",",","self",".","endPosition",")"],"url":"https:\/\/github.com\/CamDavidsonPilon\/PyProcess\/blob\/382da02d0f9732d75624538effa11caded161779\/pyprocess\/pyprocess.py#L554-L576"} {"nwo":"CamDavidsonPilon\/PyProcess","sha":"382da02d0f9732d75624538effa11caded161779","path":"pyprocess\/pyprocess.py","language":"python","identifier":"Diffusion_process.sample_position","parameters":"(self,t, N=1)","argument_list":"","return_statement":"return self._sample_position(t, N)","docstring":"if _get_position_at() is not overwritten in a subclass, this function will use euler scheme","docstring_summary":"if _get_position_at() is not overwritten in a subclass, this function will use euler scheme","docstring_tokens":["if","_get_position_at","()","is","not","overwritten","in","a","subclass","this","function","will","use","euler","scheme"],"function":"def sample_position(self,t, N=1):\n \"\"\" \n if _get_position_at() is not overwritten in a subclass, this function will use euler scheme\n \"\"\"\n\n self._check_time(t)\n return self._sample_position(t, N)","function_tokens":["def","sample_position","(","self",",","t",",","N","=","1",")",":","self",".","_check_time","(","t",")","return","self",".","_sample_position","(","t",",","N",")"],"url":"https:\/\/github.com\/CamDavidsonPilon\/PyProcess\/blob\/382da02d0f9732d75624538effa11caded161779\/pyprocess\/pyprocess.py#L578-L584"} {"nwo":"CamDavidsonPilon\/PyProcess","sha":"382da02d0f9732d75624538effa11caded161779","path":"pyprocess\/pyprocess.py","language":"python","identifier":"Diffusion_process._var","parameters":"(self,t, N = 1e6)","argument_list":"","return_statement":"return self.sample_position(t, n).var()","docstring":"var = SampleVarStat()\n for i in range(10000):\n var.push(self.generate_position_at(t))\n return var.get_variance()","docstring_summary":"var = SampleVarStat()\n for i in range(10000):\n var.push(self.generate_position_at(t))\n return var.get_variance()","docstring_tokens":["var","=","SampleVarStat","()","for","i","in","range","(","10000",")",":","var",".","push","(","self",".","generate_position_at","(","t","))","return","var",".","get_variance","()"],"function":"def _var(self,t, N = 1e6):\n \"\"\"\n var = SampleVarStat()\n for i in range(10000):\n var.push(self.generate_position_at(t))\n return var.get_variance()\n \"\"\"\n return self.sample_position(t, n).var()","function_tokens":["def","_var","(","self",",","t",",","N","=","1e6",")",":","return","self",".","sample_position","(","t",",","n",")",".","var","(",")"],"url":"https:\/\/github.com\/CamDavidsonPilon\/PyProcess\/blob\/382da02d0f9732d75624538effa11caded161779\/pyprocess\/pyprocess.py#L607-L614"} {"nwo":"CamDavidsonPilon\/PyProcess","sha":"382da02d0f9732d75624538effa11caded161779","path":"pyprocess\/pyprocess.py","language":"python","identifier":"Diffusion_process.Euler_scheme","parameters":"(self, times,delta=0.001)","argument_list":"","return_statement":"return path","docstring":"times is an array of floats.\n The process needs the methods drift() and diffusion() defined.","docstring_summary":"times is an array of floats.\n The process needs the methods drift() and diffusion() defined.","docstring_tokens":["times","is","an","array","of","floats",".","The","process","needs","the","methods","drift","()","and","diffusion","()","defined","."],"function":"def Euler_scheme(self, times,delta=0.001):\n \"\"\"\n times is an array of floats.\n The process needs the methods drift() and diffusion() defined.\n \"\"\"\n warnings.warn(\"Attn: starting an Euler scheme to approxmiate process.\")\n \n Nor = stats.norm()\n finalTime = times[-1]\n steps = int(finalTime\/delta)\n t = self.startTime\n x=self.startPosition\n path=[]\n j=0\n time = times[j]\n for i in xrange(steps):\n if t+delta>time>t:\n delta = time-t\n x += drift(x,t)*delta + np.sqrt(delta)*diffusion(x,t)*Nor.rvs()\n path.append((x,time))\n delta=0.001\n j+=1\n time = times[j]\n else:\n x += drift(x,t)*delta + np.sqrt(delta)*diffusion(x,t)*Nor.rvs()\n t += delta\n \n return path","function_tokens":["def","Euler_scheme","(","self",",","times",",","delta","=","0.001",")",":","warnings",".","warn","(","\"Attn: starting an Euler scheme to approxmiate process.\"",")","Nor","=","stats",".","norm","(",")","finalTime","=","times","[","-","1","]","steps","=","int","(","finalTime","\/","delta",")","t","=","self",".","startTime","x","=","self",".","startPosition","path","=","[","]","j","=","0","time","=","times","[","j","]","for","i","in","xrange","(","steps",")",":","if","t","+","delta",">","time",">","t",":","delta","=","time","-","t","x","+=","drift","(","x",",","t",")","*","delta","+","np",".","sqrt","(","delta",")","*","diffusion","(","x",",","t",")","*","Nor",".","rvs","(",")","path",".","append","(","(","x",",","time",")",")","delta","=","0.001","j","+=","1","time","=","times","[","j","]","else",":","x","+=","drift","(","x",",","t",")","*","delta","+","np",".","sqrt","(","delta",")","*","diffusion","(","x",",","t",")","*","Nor",".","rvs","(",")","t","+=","delta","return","path"],"url":"https:\/\/github.com\/CamDavidsonPilon\/PyProcess\/blob\/382da02d0f9732d75624538effa11caded161779\/pyprocess\/pyprocess.py#L629-L656"} {"nwo":"CamDavidsonPilon\/PyProcess","sha":"382da02d0f9732d75624538effa11caded161779","path":"pyprocess\/pyprocess.py","language":"python","identifier":"Wiener_process._sample_position","parameters":"(self,t, n=1)","argument_list":"","return_statement":"return self.mean(t) + np.sqrt(self.var(t))*self.Nor.rvs(n)","docstring":"This incorporates both conditional and unconditional","docstring_summary":"This incorporates both conditional and unconditional","docstring_tokens":["This","incorporates","both","conditional","and","unconditional"],"function":"def _sample_position(self,t, n=1):\n \"\"\"\n This incorporates both conditional and unconditional\n \"\"\"\n return self.mean(t) + np.sqrt(self.var(t))*self.Nor.rvs(n)","function_tokens":["def","_sample_position","(","self",",","t",",","n","=","1",")",":","return","self",".","mean","(","t",")","+","np",".","sqrt","(","self",".","var","(","t",")",")","*","self",".","Nor",".","rvs","(","n",")"],"url":"https:\/\/github.com\/CamDavidsonPilon\/PyProcess\/blob\/382da02d0f9732d75624538effa11caded161779\/pyprocess\/pyprocess.py#L722-L726"} {"nwo":"CamDavidsonPilon\/PyProcess","sha":"382da02d0f9732d75624538effa11caded161779","path":"pyprocess\/pyprocess.py","language":"python","identifier":"OU_process.sample_path","parameters":"(self,times, N= 1, return_normals = False)","argument_list":"","return_statement":"","docstring":"the parameter Normals = 0 is used for the Integrated OU Process","docstring_summary":"the parameter Normals = 0 is used for the Integrated OU Process","docstring_tokens":["the","parameter","Normals","=","0","is","used","for","the","Integrated","OU","Process"],"function":"def sample_path(self,times, N= 1, return_normals = False):\n \"the parameter Normals = 0 is used for the Integrated OU Process\"\n if not self.conditional:\n path=np.zeros( (N,len(times)) )\n times = np.insert( times, 0,self.startTime)\n path[ :, 0] = self.startPosition\n \n deltas = np.diff(times )\n normals = np.random.randn( N, len(times)-1 )\n x = self.startPosition*np.ones( N) \n sigma = np.sqrt(self.sigma**2*(1-np.exp(-2*self.theta*deltas))\/(2*self.theta))\n for i, delta in enumerate(deltas):\n mu = self.mu + np.exp(-self.theta*delta)*(x-self.mu)\n path[:, i] = mu + sigma[i]*normals[:,i] \n x = path[:,i]\n \"\"\"\n It would be really cool if there was a numpy func like np.cumf( func, array )\n that applies func(next_x, prev_x) to each element. For example, lambda x,y: y + x\n is the cumsum, and lambda x,y: x*y is the cumprod function.\n \"\"\"\n if return_normals:\n return (path, normals )\n else:\n return path\n \n else:\n #TODO\n path = bridge_creation(self,times)\n return path","function_tokens":["def","sample_path","(","self",",","times",",","N","=","1",",","return_normals","=","False",")",":","if","not","self",".","conditional",":","path","=","np",".","zeros","(","(","N",",","len","(","times",")",")",")","times","=","np",".","insert","(","times",",","0",",","self",".","startTime",")","path","[",":",",","0","]","=","self",".","startPosition","deltas","=","np",".","diff","(","times",")","normals","=","np",".","random",".","randn","(","N",",","len","(","times",")","-","1",")","x","=","self",".","startPosition","*","np",".","ones","(","N",")","sigma","=","np",".","sqrt","(","self",".","sigma","**","2","*","(","1","-","np",".","exp","(","-","2","*","self",".","theta","*","deltas",")",")","\/","(","2","*","self",".","theta",")",")","for","i",",","delta","in","enumerate","(","deltas",")",":","mu","=","self",".","mu","+","np",".","exp","(","-","self",".","theta","*","delta",")","*","(","x","-","self",".","mu",")","path","[",":",",","i","]","=","mu","+","sigma","[","i","]","*","normals","[",":",",","i","]","x","=","path","[",":",",","i","]","\"\"\"\n It would be really cool if there was a numpy func like np.cumf( func, array )\n that applies func(next_x, prev_x) to each element. For example, lambda x,y: y + x\n is the cumsum, and lambda x,y: x*y is the cumprod function.\n \"\"\"","if","return_normals",":","return","(","path",",","normals",")","else",":","return","path","else",":","#TODO","path","=","bridge_creation","(","self",",","times",")","return","path"],"url":"https:\/\/github.com\/CamDavidsonPilon\/PyProcess\/blob\/382da02d0f9732d75624538effa11caded161779\/pyprocess\/pyprocess.py#L832-L860"} {"nwo":"CamDavidsonPilon\/PyProcess","sha":"382da02d0f9732d75624538effa11caded161779","path":"pyprocess\/pyprocess.py","language":"python","identifier":"Integrated_OU_process.generate_sample_path","parameters":"(self,times, returnUO = 0)","argument_list":"","return_statement":"","docstring":"set returnUO to 1 to return the underlying UO path as well as the integrated UO path.","docstring_summary":"set returnUO to 1 to return the underlying UO path as well as the integrated UO path.","docstring_tokens":["set","returnUO","to","1","to","return","the","underlying","UO","path","as","well","as","the","integrated","UO","path","."],"function":"def generate_sample_path(self,times, returnUO = 0):\n \"set returnUO to 1 to return the underlying UO path as well as the integrated UO path.\"\n if not self.conditional: \n xPath, listOfNormals = self.OU.generate_sample_path(times, 1)\n path = []\n t = self.startTime\n y = self.startPosition\n for i, position in enumerate(xPath):\n delta = position[0]-t\n x = position[1]\n if delta != 0:\n #there is an error here, I can smell it.\n sigmaX = self.sigma**2*(1-np.exp(-2*self.theta*delta))\/(2*self.theta)\n sigmaY = self.sigma**2*(2*self.theta*delta-3+4*np.exp(-self.theta*delta)\n -np.exp(-2*self.theta*delta))\/(2*self.sigma**3)\n muY = y + (x-self.mu)\/self.theta + self.mu*delta-(x-self.mu)*np.exp(-self.theta*delta)\/self.theta\n covXY = self.sigma**2*(1+np.exp(-2*self.theta*delta)-2*np.exp(-self.theta*delta))\/(2*self.theta**2)\n y = muY + np.sqrt(sigmaY - covXY**2\/sigmaX)*self.Normal.rvs()+ covXY\/np.sqrt(sigmaX)*listOfNormals[i]\n t = position[0]\n path.append((t,y))\n if returnUO==0:\n return path\n else:\n return path, xPath\n else:\n path = bridge_creation(self,times)\n if returnUO==0:\n return path\n else:\n return path, xPath","function_tokens":["def","generate_sample_path","(","self",",","times",",","returnUO","=","0",")",":","if","not","self",".","conditional",":","xPath",",","listOfNormals","=","self",".","OU",".","generate_sample_path","(","times",",","1",")","path","=","[","]","t","=","self",".","startTime","y","=","self",".","startPosition","for","i",",","position","in","enumerate","(","xPath",")",":","delta","=","position","[","0","]","-","t","x","=","position","[","1","]","if","delta","!=","0",":","#there is an error here, I can smell it.","sigmaX","=","self",".","sigma","**","2","*","(","1","-","np",".","exp","(","-","2","*","self",".","theta","*","delta",")",")","\/","(","2","*","self",".","theta",")","sigmaY","=","self",".","sigma","**","2","*","(","2","*","self",".","theta","*","delta","-","3","+","4","*","np",".","exp","(","-","self",".","theta","*","delta",")","-","np",".","exp","(","-","2","*","self",".","theta","*","delta",")",")","\/","(","2","*","self",".","sigma","**","3",")","muY","=","y","+","(","x","-","self",".","mu",")","\/","self",".","theta","+","self",".","mu","*","delta","-","(","x","-","self",".","mu",")","*","np",".","exp","(","-","self",".","theta","*","delta",")","\/","self",".","theta","covXY","=","self",".","sigma","**","2","*","(","1","+","np",".","exp","(","-","2","*","self",".","theta","*","delta",")","-","2","*","np",".","exp","(","-","self",".","theta","*","delta",")",")","\/","(","2","*","self",".","theta","**","2",")","y","=","muY","+","np",".","sqrt","(","sigmaY","-","covXY","**","2","\/","sigmaX",")","*","self",".","Normal",".","rvs","(",")","+","covXY","\/","np",".","sqrt","(","sigmaX",")","*","listOfNormals","[","i","]","t","=","position","[","0","]","path",".","append","(","(","t",",","y",")",")","if","returnUO","==","0",":","return","path","else",":","return","path",",","xPath","else",":","path","=","bridge_creation","(","self",",","times",")","if","returnUO","==","0",":","return","path","else",":","return","path",",","xPath"],"url":"https:\/\/github.com\/CamDavidsonPilon\/PyProcess\/blob\/382da02d0f9732d75624538effa11caded161779\/pyprocess\/pyprocess.py#L915-L944"} {"nwo":"CamDavidsonPilon\/PyProcess","sha":"382da02d0f9732d75624538effa11caded161779","path":"pyprocess\/pyprocess.py","language":"python","identifier":"SqBessel_process.generate_sample_path","parameters":"(self,times,absb=0)","argument_list":"","return_statement":"","docstring":"absb is a boolean, true if absorbtion at 0, false else. See class' __doc__ for when \n absorbtion is valid.","docstring_summary":"absb is a boolean, true if absorbtion at 0, false else. See class' __doc__ for when \n absorbtion is valid.","docstring_tokens":["absb","is","a","boolean","true","if","absorbtion","at","0","false","else",".","See","class","__doc__","for","when","absorbtion","is","valid","."],"function":"def generate_sample_path(self,times,absb=0):\n \"\"\"\n absb is a boolean, true if absorbtion at 0, false else. See class' __doc__ for when \n absorbtion is valid.\n \"\"\"\n if absb:\n return self._generate_sample_path_with_absorption(times)\n else:\n return self._generate_sample_path_no_absorption(times)","function_tokens":["def","generate_sample_path","(","self",",","times",",","absb","=","0",")",":","if","absb",":","return","self",".","_generate_sample_path_with_absorption","(","times",")","else",":","return","self",".","_generate_sample_path_no_absorption","(","times",")"],"url":"https:\/\/github.com\/CamDavidsonPilon\/PyProcess\/blob\/382da02d0f9732d75624538effa11caded161779\/pyprocess\/pyprocess.py#L987-L995"} {"nwo":"CamDavidsonPilon\/PyProcess","sha":"382da02d0f9732d75624538effa11caded161779","path":"pyprocess\/pyprocess.py","language":"python","identifier":"SqBessel_process._generate_sample_path_no_absorption","parameters":"(self, times)","argument_list":"","return_statement":"","docstring":"mu must be greater than -1. The parameter times is a list of times to sample at.","docstring_summary":"mu must be greater than -1. The parameter times is a list of times to sample at.","docstring_tokens":["mu","must","be","greater","than","-","1",".","The","parameter","times","is","a","list","of","times","to","sample","at","."],"function":"def _generate_sample_path_no_absorption(self, times):\n \"mu must be greater than -1. The parameter times is a list of times to sample at.\"\n if self.mu<=-1:\n print \"Attn: mu must be greater than -1. It is currently %f.\"%self.mu\n return\n else:\n if not self.conditional:\n x=self.startPosition\n t=self.startTime\n path=[]\n for time in times:\n delta=float(time-t)\n try:\n y=self.Poi.rvs(0.5*x\/delta)\n x=self.Gamma.rvs(y+self.mu+1)*2*delta\n except:\n pass\n path.append((time,x))\n t=time\n else:\n path = bridge_creation(self, times, 0)\n return path\n return [(p[0],self.rescalePath(p[1])) for p in path]","function_tokens":["def","_generate_sample_path_no_absorption","(","self",",","times",")",":","if","self",".","mu","<=","-","1",":","print","\"Attn: mu must be greater than -1. It is currently %f.\"","%","self",".","mu","return","else",":","if","not","self",".","conditional",":","x","=","self",".","startPosition","t","=","self",".","startTime","path","=","[","]","for","time","in","times",":","delta","=","float","(","time","-","t",")","try",":","y","=","self",".","Poi",".","rvs","(","0.5","*","x","\/","delta",")","x","=","self",".","Gamma",".","rvs","(","y","+","self",".","mu","+","1",")","*","2","*","delta","except",":","pass","path",".","append","(","(","time",",","x",")",")","t","=","time","else",":","path","=","bridge_creation","(","self",",","times",",","0",")","return","path","return","[","(","p","[","0","]",",","self",".","rescalePath","(","p","[","1","]",")",")","for","p","in","path","]"],"url":"https:\/\/github.com\/CamDavidsonPilon\/PyProcess\/blob\/382da02d0f9732d75624538effa11caded161779\/pyprocess\/pyprocess.py#L1004-L1026"} {"nwo":"CamDavidsonPilon\/PyProcess","sha":"382da02d0f9732d75624538effa11caded161779","path":"pyprocess\/pyprocess.py","language":"python","identifier":"SqBessel_process._generate_sample_path_with_absorption","parameters":"(self,times)","argument_list":"","return_statement":"","docstring":"mu must be less than 0.","docstring_summary":"mu must be less than 0.","docstring_tokens":["mu","must","be","less","than","0","."],"function":"def _generate_sample_path_with_absorption(self,times):\n \"mu must be less than 0.\"\n if self.mu>=0:\n print \"Attn: mu must be less than 0. It is currently %f.\"%self.mu\n else:\n if not self.conditional:\n path=[]\n X=self.startPosition\n t=self.startTime\n tauEst=times[-1]+1\n for time in times:\n delta = float(time - t)\n if tauEst>times[-1]:\n p_a = gammaincc(abs(self.mu),0.5*X\/(delta))\n if np.random.rand() < p_a:\n tauEst = time\n if time=","0",":","print","\"Attn: mu must be less than 0. It is currently %f.\"","%","self",".","mu","else",":","if","not","self",".","conditional",":","path","=","[","]","X","=","self",".","startPosition","t","=","self",".","startTime","tauEst","=","times","[","-","1","]","+","1","for","time","in","times",":","delta","=","float","(","time","-","t",")","if","tauEst",">","times","[","-","1","]",":","p_a","=","gammaincc","(","abs","(","self",".","mu",")",",","0.5","*","X","\/","(","delta",")",")","if","np",".","random",".","rand","(",")","<","p_a",":","tauEst","=","time","if","time","<","tauEst",":","Y","=","self",".","InGamma",".","rvs","(","abs","(","self",".","mu",")",",","0.5","*","X","\/","(","delta",")",")","X","=","self",".","Gamma",".","rvs","(","Y","+","1",")","*","2","*","delta","else",":","X","=","0","t","=","time","path",".","append","(","(","t",",","X",")",")","else",":","path","=","bridge_creation","(","self",",","times",",","1",")","return","[","(","p","[","0","]",",","self",".","rescalePath","(","p","[","1","]",")",")","for","p","in","path","]"],"url":"https:\/\/github.com\/CamDavidsonPilon\/PyProcess\/blob\/382da02d0f9732d75624538effa11caded161779\/pyprocess\/pyprocess.py#L1030-L1055"} {"nwo":"CamDavidsonPilon\/PyProcess","sha":"382da02d0f9732d75624538effa11caded161779","path":"pyprocess\/pyprocess.py","language":"python","identifier":"SqBessel_process.generate_sample_FHT_bridge","parameters":"(self,times)","argument_list":"","return_statement":"","docstring":"mu must be less than 0. This process has absorption at L=0. It simulates the absorption at 0 at some random time, tao, and creates a bridge process.","docstring_summary":"mu must be less than 0. This process has absorption at L=0. It simulates the absorption at 0 at some random time, tao, and creates a bridge process.","docstring_tokens":["mu","must","be","less","than","0",".","This","process","has","absorption","at","L","=","0",".","It","simulates","the","absorption","at","0","at","some","random","time","tao","and","creates","a","bridge","process","."],"function":"def generate_sample_FHT_bridge(self,times):\n \"mu must be less than 0. This process has absorption at L=0. It simulates the absorption at 0 at some random time, tao, and creates a bridge process.\"\n if self.mu>0:\n print \"mu must be less than 0. It is currently %f.\"%self.mu\n else:\n X=self.startPosition\n t=self.t_0\n path=[]\n FHT=self.startPosition\/(2*self.Gamma.rvs(abs(self.mu)))\n for time in times:\n if time","0",":","print","\"mu must be less than 0. It is currently %f.\"","%","self",".","mu","else",":","X","=","self",".","startPosition","t","=","self",".","t_0","path","=","[","]","FHT","=","self",".","startPosition","\/","(","2","*","self",".","Gamma",".","rvs","(","abs","(","self",".","mu",")",")",")","for","time","in","times",":","if","time","<","FHT",":","d","=","(","FHT","-","t",")","*","(","time","-","t",")","Y","=","self",".","Poi",".","rvs","(","X","*","(","FHT","-","time",")","\/","(","2","*","d",")",")","X","=","self",".","Gamma",".","rvs","(","Y","-","self",".","mu","+","1",")","*","d","\/","(","FHT","-","t",")","else",":","X","=","0","t","=","time","path",".","append","(","(","t",",","X",")",")","return","[","(","p","[","0","]",",","self",".","rescalePath","(","p","[","1","]",")",")","for","p","in","path","]"],"url":"https:\/\/github.com\/CamDavidsonPilon\/PyProcess\/blob\/382da02d0f9732d75624538effa11caded161779\/pyprocess\/pyprocess.py#L1063-L1081"} {"nwo":"CamDavidsonPilon\/PyProcess","sha":"382da02d0f9732d75624538effa11caded161779","path":"pyprocess\/pyprocess.py","language":"python","identifier":"CIR_process.generate_sample_path","parameters":"(self, times, abs=0)","argument_list":"","return_statement":"return path","docstring":"abs is a boolean: true if desire nonzero probability of absorption at 0, false else.","docstring_summary":"abs is a boolean: true if desire nonzero probability of absorption at 0, false else.","docstring_tokens":["abs","is","a","boolean",":","true","if","desire","nonzero","probability","of","absorption","at","0","false","else","."],"function":"def generate_sample_path(self, times, abs=0):\n \"abs is a boolean: true if desire nonzero probability of absorption at 0, false else.\"\n #first, transform times:\n transformedTimes = [self._time_transformation(t) for t in times]\n path = self.SqB.generate_sample_path(transformedTimes,abs)\n tpath = [self._space_transformation(times[i],p[1]) for i,p in enumerate(path) ]\n path=[]\n for i in xrange(len(tpath)):\n path.append((times[i],tpath[i]))\n return path","function_tokens":["def","generate_sample_path","(","self",",","times",",","abs","=","0",")",":","#first, transform times:","transformedTimes","=","[","self",".","_time_transformation","(","t",")","for","t","in","times","]","path","=","self",".","SqB",".","generate_sample_path","(","transformedTimes",",","abs",")","tpath","=","[","self",".","_space_transformation","(","times","[","i","]",",","p","[","1","]",")","for","i",",","p","in","enumerate","(","path",")","]","path","=","[","]","for","i","in","xrange","(","len","(","tpath",")",")",":","path",".","append","(","(","times","[","i","]",",","tpath","[","i","]",")",")","return","path"],"url":"https:\/\/github.com\/CamDavidsonPilon\/PyProcess\/blob\/382da02d0f9732d75624538effa11caded161779\/pyprocess\/pyprocess.py#L1129-L1138"} {"nwo":"CamDavidsonPilon\/PyProcess","sha":"382da02d0f9732d75624538effa11caded161779","path":"pyprocess\/pyprocess.py","language":"python","identifier":"Periodic_drift_process.__init__","parameters":"(self, parameters, space_time_constraints)","argument_list":"","return_statement":"","docstring":"Note that space-time constraints cannot be given","docstring_summary":"Note that space-time constraints cannot be given","docstring_tokens":["Note","that","space","-","time","constraints","cannot","be","given"],"function":"def __init__(self, parameters, space_time_constraints):\n \"\"\"Note that space-time constraints cannot be given\"\"\"\n space_time_constraints = {\"startTime\":0, \"startPosition\":0}\n super(Periodic_drift_process,self).__init__(space_time_constraints)\n self.psi = parameters[\"psi\"]\n self.theta = parameters[\"theta\"]\n self._findBounds() \n self.BB = Wiener_process({\"mu\":0, \"sigma\":1}, space_time_constraints)\n self.Poi = Marked_poisson_process({\"rate\":1, \"U\":self.max, \"L\":self.min, \"startTime\":0}) #need to create marked poisson process class\n self.Nor = stats.norm\n self.Uni = stats.uniform()","function_tokens":["def","__init__","(","self",",","parameters",",","space_time_constraints",")",":","space_time_constraints","=","{","\"startTime\"",":","0",",","\"startPosition\"",":","0","}","super","(","Periodic_drift_process",",","self",")",".","__init__","(","space_time_constraints",")","self",".","psi","=","parameters","[","\"psi\"","]","self",".","theta","=","parameters","[","\"theta\"","]","self",".","_findBounds","(",")","self",".","BB","=","Wiener_process","(","{","\"mu\"",":","0",",","\"sigma\"",":","1","}",",","space_time_constraints",")","self",".","Poi","=","Marked_poisson_process","(","{","\"rate\"",":","1",",","\"U\"",":","self",".","max",",","\"L\"",":","self",".","min",",","\"startTime\"",":","0","}",")","#need to create marked poisson process class","self",".","Nor","=","stats",".","norm","self",".","Uni","=","stats",".","uniform","(",")"],"url":"https:\/\/github.com\/CamDavidsonPilon\/PyProcess\/blob\/382da02d0f9732d75624538effa11caded161779\/pyprocess\/pyprocess.py#L1239-L1249"} {"nwo":"CamDavidsonPilon\/PyProcess","sha":"382da02d0f9732d75624538effa11caded161779","path":"pyprocess\/pyprocess.py","language":"python","identifier":"Periodic_drift_process.generate_sample_path","parameters":"(self,times)","argument_list":"","return_statement":"return self._construct_path_from_skeleton([(0,self.startPosition)]+skeleton, times)","docstring":"currently will only return a random path before time T. Can be connected by brownian bridges","docstring_summary":"currently will only return a random path before time T. Can be connected by brownian bridges","docstring_tokens":["currently","will","only","return","a","random","path","before","time","T",".","Can","be","connected","by","brownian","bridges"],"function":"def generate_sample_path(self,times):\n \"currently will only return a random path before time T. Can be connected by brownian bridges\"\n #this algorithm uses the EA1 algorithm by Beskos and \n # Roberts on exact simulation of diffusions. It's an AR algorithm.\n # For some parameters, the probability of acceptance can be very low.\n time = 0\n endPoint = 0\n skeleton=[]\n T = times[-1]\n while timePub and lb>=0:\n sum+=Plb\n pos = lb\n Plb = (lb+shape)\/scale*Plb\n lb-=1\n else:\n sum+=Pub\n pos= ub\n Pub = scale\/(ub+1+shape)*Pub\n ub+=1\n return float(pos)","function_tokens":["def","rvs","(","self",",","shape",",","scale",")",":","pos","=","mode","=","float","(","max","(","0",",","int","(","shape","-","scale",")",")",")","U","=","self",".","Uni",".","rvs","(",")","sum","=","self",".","pdf","(","mode",",","shape",",","scale",")","ub","=","mode","+","1","lb","=","mode","-","1","Pub","=","sum","*","scale","\/","(","mode","+","1","+","shape",")","Plb","=","sum","*","(","mode","+","shape",")","\/","scale","while","sum","<","U",":","if","Plb",">","Pub","and","lb",">=","0",":","sum","+=","Plb","pos","=","lb","Plb","=","(","lb","+","shape",")","\/","scale","*","Plb","lb","-=","1","else",":","sum","+=","Pub","pos","=","ub","Pub","=","scale","\/","(","ub","+","1","+","shape",")","*","Pub","ub","+=","1","return","float","(","pos",")"],"url":"https:\/\/github.com\/CamDavidsonPilon\/PyProcess\/blob\/382da02d0f9732d75624538effa11caded161779\/pyprocess\/pyprocess.py#L1982-L2003"}