├── main.pdf ├── .gitignore ├── main.py ├── GaussianProcessMultiDim.py ├── README.md ├── cymath.pyx ├── testdata1d_000.txt ├── testdata1d_001.txt ├── testdata1d_002.txt ├── testdata1d_003.txt ├── testdata1d_004.txt ├── GaussianProcess.pyx ├── testdata2d_003.txt ├── testdata2d_004.txt ├── testdata2d_000.txt ├── testdata2d_001.txt ├── testdata2d_002.txt ├── GPSegmentation.py └── LICENSE /main.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/naka-lab/GP-HSMM/HEAD/main.pdf -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | GaussianProcess\.so 3 | 4 | \.DS_Store 5 | 6 | *.pyc 7 | 8 | local_data/ 9 | 10 | learn/ 11 | 12 | recog/ 13 | 14 | *.so 15 | 16 | *.pyd 17 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import unicode_literals 3 | from __future__ import print_function 4 | from GPSegmentation import GPSegmentation 5 | import time 6 | 7 | def learn( savedir ): 8 | gpsegm = GPSegmentation(2,5) 9 | 10 | files = [ "testdata2d_%03d.txt" % j for j in range(4) ] 11 | gpsegm.load_data( files ) 12 | 13 | start = time.time() 14 | for it in range(5): 15 | print( "-----", it, "-----" ) 16 | gpsegm.learn() 17 | gpsegm.save_model( savedir ) 18 | print( "lik =", gpsegm.calc_lik() ) 19 | print( time.time()-start ) 20 | return gpsegm.calc_lik() 21 | 22 | 23 | def recog( modeldir, savedir ): 24 | gpsegm = GPSegmentation(2,5) 25 | 26 | gpsegm.load_data( [ "testdata2d_%03d.txt" % j for j in range(4) ] ) 27 | gpsegm.load_model( modeldir ) 28 | 29 | 30 | start = time.time() 31 | gpsegm.recog() 32 | print( "lik =", gpsegm.calc_lik() ) 33 | print( time.time()-start ) 34 | gpsegm.save_model( savedir ) 35 | 36 | 37 | def main(): 38 | learn( "learn/" ) 39 | recog( "learn/" , "recog/" ) 40 | return 41 | 42 | if __name__=="__main__": 43 | main() 44 | -------------------------------------------------------------------------------- /GaussianProcessMultiDim.py: -------------------------------------------------------------------------------- 1 | # encoding: utf8 2 | from __future__ import unicode_literals 3 | from __future__ import print_function 4 | import pyximport 5 | import numpy as np 6 | pyximport.install(setup_args={'include_dirs':[np.get_include()]}, inplace=True) 7 | import GaussianProcess 8 | import matplotlib.pyplot as plt 9 | 10 | 11 | class GPMD: 12 | def __init__(self, dim): 13 | self.__dim = dim 14 | self.__gp = [ GaussianProcess.GP() for d in range(self.__dim) ] 15 | 16 | def learn(self,x, y, same_cov=True ): 17 | y = np.array(y, dtype=float).reshape( (-1,self.__dim) ) 18 | x = np.array(x,dtype=float) 19 | i_cov = None 20 | 21 | for d in range(self.__dim): 22 | if not same_cov: 23 | i_cov = None 24 | 25 | if len(y)!=0: 26 | i_cov = self.__gp[d].learn( x, y[:,d], i_cov ) 27 | else: 28 | i_cov = self.__gp[d].learn( x, np.array([]), i_cov ) 29 | 30 | 31 | 32 | 33 | def calc_lik(self, x, y ): 34 | lik = 0.0 35 | 36 | if self.__dim==1: 37 | y = np.asarray(y, dtype=float).reshape( (-1,self.__dim) ) 38 | #x = np.asarray(x,dtype=np.float) 39 | for d in range(self.__dim): 40 | lik += self.__gp[d].calc_lik( x , y[:,d] ) 41 | 42 | return lik 43 | 44 | def plot(self, x ): 45 | for d in range(self.__dim): 46 | plt.subplot( self.__dim, 1, d+1 ) 47 | 48 | mus, sigmas = self.__gp[d].predict(x) 49 | y_min = mus - sigmas*2 50 | y_max = mus + sigmas*2 51 | 52 | plt.fill_between( x, y_min, y_max, facecolor="lavender" , alpha=0.9 , edgecolor="lavender" ) 53 | plt.plot(x, y_min, 'b--') 54 | plt.plot(x, mus, 'b-') 55 | plt.plot(x, y_max, 'b--') 56 | 57 | def predict(self, x ): 58 | params = [] 59 | for d in range(self.__dim): 60 | mus, sigmas = self.__gp[d].predict(np.array(x, dtype=float)) 61 | params.append( (mus, sigmas) ) 62 | return params 63 | 64 | def estimate_hyperparams(self, niter): 65 | for d in range(self.__dim): 66 | self.__gp[d].estimate_hyperparams(niter) 67 | 68 | 69 | def main(): 70 | pass 71 | 72 | if __name__ == '__main__': 73 | main() -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GP-HSMM 2 | 3 | This is an implementation of time series data segmentation using Gaussian Processes (GP) and Hidden Semi-Markov Models (HSMM). For details, please refer to the following paper: 4 | 5 | Tomoaki Nakamura, Takayuki Nagai, Daichi Mochihashi, Ichiro Kobayashi, Hideki Asoh and Masahide Kaneko, “Segmenting Continuous Motions with Hidden Semi-Markov Models and Gaussian Processes”, Frontiers in Neurorobotics, vol.11, article 67, pp. 1-11, Dec. 2017 [[PDF]](https://github.com/naka-lab/GP-HSMM/raw/master/main.pdf) 6 | 7 | **A fast and scalable implementation called [RFF-GP-HSMM](https://github.com/naka-lab/RFF-GP-HSMM), which solves the slow computation problem of GP-HSMM, is also available.** 8 | 9 | 10 | ## How to Run 11 | 12 | ``` 13 | python main.py 14 | ``` 15 | 16 | Programs written in Cython will be automatically compiled at runtime. 17 | If you encounter compilation errors with the Visual Studio compiler on Windows, please edit: 18 | 19 | ``` 20 | (Python installation directory)/Lib/distutils/msvc9compiler.py 21 | ``` 22 | 23 | Inside the `get_build_version()` function, replace the following line: 24 | 25 | ``` 26 | majorVersion = int(s[:-2]) - 6 27 | ``` 28 | 29 | with the version number of the Visual Studio you wish to use. 30 | For example, for VS2012, set: 31 | 32 | ``` 33 | majorVersion = 11 34 | ``` 35 | 36 | ## Output Files 37 | 38 | When executed, the following files and directories will be created in the specified folder: 39 | 40 | | File Name| Description | 41 | | ---- | --- | 42 | | class{c}.npy | A collection of segments classified into class c | 43 | | class{c}\_dim{d}.png | Plot of the d-th dimension of segments classified into class c | 44 | | segm{n}.txt | Segmentation result of the n-th sequence. Column 1: segment class, Column 2: flag indicating segment boundary | 45 | | trans\_bos.npy | Probability that each class appears at the beginning of a sequence | 46 | | trans\_eos.npy | Probability that each class appears at the end of a sequence | 47 | | trans.npy | Transition probabilities of each class appearing after a given class | 48 | 49 | 50 | # LICENSE 51 | This program is freely available for free non-commercial use. 52 | If you publish results obtained using this program, please cite: 53 | 54 | ``` 55 | @article{nakamura2017segmenting, 56 | title={Segmenting continuous motions with hidden semi-markov models and gaussian processes}, 57 | author={Nakamura, Tomoaki and Nagai, Takayuki and Mochihashi, Daichi and Kobayashi, Ichiro and Asoh, Hideki and Kaneko, Masahide}, 58 | journal={Frontiers in neurorobotics}, 59 | volume={11}, 60 | pages={67}, 61 | year={2017}, 62 | publisher={Frontiers} 63 | } 64 | ``` 65 | -------------------------------------------------------------------------------- /cymath.pyx: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | from __future__ import unicode_literals 4 | import numpy as np 5 | import random 6 | import matplotlib.mlab as mlab 7 | import sys 8 | import math 9 | 10 | cdef extern from "math.h": 11 | double log(double) 12 | double exp(double) 13 | 14 | 15 | cpdef logsumexp( double[:,:] a ): 16 | cdef double max_val = -sys.float_info.max 17 | cdef double sum_exp = 0 18 | cdef int I = a.shape[0] 19 | cdef int J = a.shape[1] 20 | 21 | for i in range(I): 22 | for j in range(J): 23 | if max_valb: 36 | max_val = a 37 | else: 38 | max_val = b 39 | 40 | sum_exp = exp(a-max_val)+ exp(b-max_val) 41 | return log(sum_exp) + max_val 42 | 43 | cpdef calc_forward_probability(double[:,:,:] emission_prob_all, double[:,:] trans_prob, double[:] trans_prob_bos, double[:] trans_prob_eos, int T, int MIN_LEN, int SKIP_LEN, int MAX_LEN, int num_class): 44 | cdef int t, k, c, tt, kk, cc 45 | cdef double foward_prob 46 | cdef double[:,:,:] log_a = np.zeros( (T, MAX_LEN, num_class) ) - 99999999999999 47 | cdef double[:,:,:] valid = np.zeros( (T, MAX_LEN, num_class) ) # 計算された有効な値可どうか.計算されていない場所の確率を0にするため. 48 | cdef double[:] z = np.ones( T ) # 正規化定数 49 | cdef double[:,:] m = np.zeros( (T, num_class) ) # t-kの計算結果を入れるバッファ 50 | 51 | for t in range(T): 52 | for k in range(MIN_LEN, MAX_LEN, SKIP_LEN): 53 | if t-k<0: 54 | break 55 | 56 | for c in range(num_class): 57 | out_prob = emission_prob_all[c,k,t-k] 58 | foward_prob = 0.0 59 | 60 | # 遷移確率 61 | tt = t-k-1 62 | if tt>=0: 63 | #if m[tt]==0: 64 | # m[tt] = logsumexp( log_a[tt,:,:] + z[tt] + np.log(trans_prob[:,c]) ) 65 | #foward_prob = m[tt] + out_prob 66 | 67 | if m[tt,c]==0: 68 | s = -999999999999 69 | for kk in range(MAX_LEN): 70 | for cc in range(num_class): 71 | s = _logsumexp( s, log_a[tt,kk,cc] + z[tt] + log(trans_prob[cc, c])) 72 | m[tt,c] = s 73 | foward_prob = m[tt,c] + out_prob 74 | else: 75 | # 最初の単語 76 | foward_prob = out_prob + log(trans_prob_bos[c]) 77 | 78 | if t==T-1: 79 | # 最後の単語 80 | foward_prob += log(trans_prob_eos[c]) 81 | 82 | # 正規化を元に戻す 83 | log_a[t,k,c] = foward_prob 84 | valid[t,k,c] = 1.0 85 | if math.isnan(foward_prob): 86 | print( "a[t=%d,k=%d,c=%d] became NAN!!" % (t,k,c) ) 87 | sys.exit(-1) 88 | # 正規化 89 | if t-MIN_LEN>=0: 90 | z[t] = logsumexp( log_a[t,:,:] ) 91 | #log_a[t,:,:] -= z[t] 92 | for k in range(MAX_LEN): 93 | for c in range(num_class): 94 | log_a[t, k, c] -= z[t] 95 | 96 | return np.exp(log_a)*valid 97 | -------------------------------------------------------------------------------- /testdata1d_000.txt: -------------------------------------------------------------------------------- 1 | 0.000000000000000000e+00 2 | 1.000000000000000000e+00 3 | 1.000000000000000000e+00 4 | 1.000000000000000000e+00 5 | 1.000000000000000000e+00 6 | 1.000000000000000000e+00 7 | 0.000000000000000000e+00 8 | 0.000000000000000000e+00 9 | 1.000000000000000000e+00 10 | 1.000000000000000000e+00 11 | 1.000000000000000000e+00 12 | 1.000000000000000000e+00 13 | 1.000000000000000000e+00 14 | 0.000000000000000000e+00 15 | 0.000000000000000000e+00 16 | 0.000000000000000000e+00 17 | 0.000000000000000000e+00 18 | 0.000000000000000000e+00 19 | 0.000000000000000000e+00 20 | 0.000000000000000000e+00 21 | 0.000000000000000000e+00 22 | 0.000000000000000000e+00 23 | 1.000000000000000000e+00 24 | 1.000000000000000000e+00 25 | 1.000000000000000000e+00 26 | 1.000000000000000000e+00 27 | 1.000000000000000000e+00 28 | 0.000000000000000000e+00 29 | 0.000000000000000000e+00 30 | 0.000000000000000000e+00 31 | 0.000000000000000000e+00 32 | 0.000000000000000000e+00 33 | 0.000000000000000000e+00 34 | 0.000000000000000000e+00 35 | 0.000000000000000000e+00 36 | 0.000000000000000000e+00 37 | 3.300000000000000155e-01 38 | 6.600000000000000311e-01 39 | 1.000000000000000000e+00 40 | 6.600000000000000311e-01 41 | 3.300000000000000155e-01 42 | 0.000000000000000000e+00 43 | 0.000000000000000000e+00 44 | 0.000000000000000000e+00 45 | 0.000000000000000000e+00 46 | 0.000000000000000000e+00 47 | 0.000000000000000000e+00 48 | 0.000000000000000000e+00 49 | 0.000000000000000000e+00 50 | 0.000000000000000000e+00 51 | 1.000000000000000000e+00 52 | 1.000000000000000000e+00 53 | 1.000000000000000000e+00 54 | 1.000000000000000000e+00 55 | 1.000000000000000000e+00 56 | 0.000000000000000000e+00 57 | 0.000000000000000000e+00 58 | 1.000000000000000000e+00 59 | 1.000000000000000000e+00 60 | 1.000000000000000000e+00 61 | 1.000000000000000000e+00 62 | 1.000000000000000000e+00 63 | 0.000000000000000000e+00 64 | 0.000000000000000000e+00 65 | 1.000000000000000000e+00 66 | 1.000000000000000000e+00 67 | 1.000000000000000000e+00 68 | 1.000000000000000000e+00 69 | 1.000000000000000000e+00 70 | 0.000000000000000000e+00 71 | 0.000000000000000000e+00 72 | 1.000000000000000000e+00 73 | 1.000000000000000000e+00 74 | 1.000000000000000000e+00 75 | 1.000000000000000000e+00 76 | 1.000000000000000000e+00 77 | 0.000000000000000000e+00 78 | 0.000000000000000000e+00 79 | 1.000000000000000000e+00 80 | 1.000000000000000000e+00 81 | 1.000000000000000000e+00 82 | 1.000000000000000000e+00 83 | 1.000000000000000000e+00 84 | 0.000000000000000000e+00 85 | 0.000000000000000000e+00 86 | 1.000000000000000000e+00 87 | 1.000000000000000000e+00 88 | 1.000000000000000000e+00 89 | 1.000000000000000000e+00 90 | 1.000000000000000000e+00 91 | 0.000000000000000000e+00 92 | 0.000000000000000000e+00 93 | 1.000000000000000000e+00 94 | 1.000000000000000000e+00 95 | 1.000000000000000000e+00 96 | 1.000000000000000000e+00 97 | 1.000000000000000000e+00 98 | 0.000000000000000000e+00 99 | 0.000000000000000000e+00 100 | 1.000000000000000000e+00 101 | 1.000000000000000000e+00 102 | 1.000000000000000000e+00 103 | 1.000000000000000000e+00 104 | 1.000000000000000000e+00 105 | 0.000000000000000000e+00 106 | 0.000000000000000000e+00 107 | 0.000000000000000000e+00 108 | 0.000000000000000000e+00 109 | 0.000000000000000000e+00 110 | 0.000000000000000000e+00 111 | 0.000000000000000000e+00 112 | 0.000000000000000000e+00 113 | 0.000000000000000000e+00 114 | 3.300000000000000155e-01 115 | 6.600000000000000311e-01 116 | 1.000000000000000000e+00 117 | 6.600000000000000311e-01 118 | 3.300000000000000155e-01 119 | 0.000000000000000000e+00 120 | 0.000000000000000000e+00 121 | 0.000000000000000000e+00 122 | 0.000000000000000000e+00 123 | 0.000000000000000000e+00 124 | 0.000000000000000000e+00 125 | 0.000000000000000000e+00 126 | 0.000000000000000000e+00 127 | 0.000000000000000000e+00 128 | 1.000000000000000000e+00 129 | 1.000000000000000000e+00 130 | 1.000000000000000000e+00 131 | 1.000000000000000000e+00 132 | 1.000000000000000000e+00 133 | 0.000000000000000000e+00 134 | 0.000000000000000000e+00 135 | 0.000000000000000000e+00 136 | 0.000000000000000000e+00 137 | 0.000000000000000000e+00 138 | 0.000000000000000000e+00 139 | 0.000000000000000000e+00 140 | 0.000000000000000000e+00 141 | -------------------------------------------------------------------------------- /testdata1d_001.txt: -------------------------------------------------------------------------------- 1 | 0.000000000000000000e+00 2 | 1.000000000000000000e+00 3 | 1.000000000000000000e+00 4 | 1.000000000000000000e+00 5 | 1.000000000000000000e+00 6 | 1.000000000000000000e+00 7 | 0.000000000000000000e+00 8 | 0.000000000000000000e+00 9 | 1.000000000000000000e+00 10 | 1.000000000000000000e+00 11 | 1.000000000000000000e+00 12 | 1.000000000000000000e+00 13 | 1.000000000000000000e+00 14 | 0.000000000000000000e+00 15 | 0.000000000000000000e+00 16 | 1.000000000000000000e+00 17 | 1.000000000000000000e+00 18 | 1.000000000000000000e+00 19 | 1.000000000000000000e+00 20 | 1.000000000000000000e+00 21 | 0.000000000000000000e+00 22 | 0.000000000000000000e+00 23 | 1.000000000000000000e+00 24 | 1.000000000000000000e+00 25 | 1.000000000000000000e+00 26 | 1.000000000000000000e+00 27 | 1.000000000000000000e+00 28 | 0.000000000000000000e+00 29 | 0.000000000000000000e+00 30 | 1.000000000000000000e+00 31 | 1.000000000000000000e+00 32 | 1.000000000000000000e+00 33 | 1.000000000000000000e+00 34 | 1.000000000000000000e+00 35 | 0.000000000000000000e+00 36 | 0.000000000000000000e+00 37 | 0.000000000000000000e+00 38 | 0.000000000000000000e+00 39 | 0.000000000000000000e+00 40 | 0.000000000000000000e+00 41 | 0.000000000000000000e+00 42 | 0.000000000000000000e+00 43 | 0.000000000000000000e+00 44 | 1.000000000000000000e+00 45 | 1.000000000000000000e+00 46 | 1.000000000000000000e+00 47 | 1.000000000000000000e+00 48 | 1.000000000000000000e+00 49 | 0.000000000000000000e+00 50 | 0.000000000000000000e+00 51 | 1.000000000000000000e+00 52 | 1.000000000000000000e+00 53 | 1.000000000000000000e+00 54 | 1.000000000000000000e+00 55 | 1.000000000000000000e+00 56 | 0.000000000000000000e+00 57 | 0.000000000000000000e+00 58 | 0.000000000000000000e+00 59 | 0.000000000000000000e+00 60 | 0.000000000000000000e+00 61 | 0.000000000000000000e+00 62 | 0.000000000000000000e+00 63 | 0.000000000000000000e+00 64 | 0.000000000000000000e+00 65 | 1.000000000000000000e+00 66 | 1.000000000000000000e+00 67 | 1.000000000000000000e+00 68 | 1.000000000000000000e+00 69 | 1.000000000000000000e+00 70 | 0.000000000000000000e+00 71 | 0.000000000000000000e+00 72 | 0.000000000000000000e+00 73 | 0.000000000000000000e+00 74 | 0.000000000000000000e+00 75 | 0.000000000000000000e+00 76 | 0.000000000000000000e+00 77 | 0.000000000000000000e+00 78 | 0.000000000000000000e+00 79 | 1.000000000000000000e+00 80 | 1.000000000000000000e+00 81 | 1.000000000000000000e+00 82 | 1.000000000000000000e+00 83 | 1.000000000000000000e+00 84 | 0.000000000000000000e+00 85 | 0.000000000000000000e+00 86 | 1.000000000000000000e+00 87 | 1.000000000000000000e+00 88 | 1.000000000000000000e+00 89 | 1.000000000000000000e+00 90 | 1.000000000000000000e+00 91 | 0.000000000000000000e+00 92 | 0.000000000000000000e+00 93 | 1.000000000000000000e+00 94 | 1.000000000000000000e+00 95 | 1.000000000000000000e+00 96 | 1.000000000000000000e+00 97 | 1.000000000000000000e+00 98 | 0.000000000000000000e+00 99 | 0.000000000000000000e+00 100 | 1.000000000000000000e+00 101 | 1.000000000000000000e+00 102 | 1.000000000000000000e+00 103 | 1.000000000000000000e+00 104 | 1.000000000000000000e+00 105 | 0.000000000000000000e+00 106 | 0.000000000000000000e+00 107 | 1.000000000000000000e+00 108 | 1.000000000000000000e+00 109 | 1.000000000000000000e+00 110 | 1.000000000000000000e+00 111 | 1.000000000000000000e+00 112 | 0.000000000000000000e+00 113 | 0.000000000000000000e+00 114 | 0.000000000000000000e+00 115 | 0.000000000000000000e+00 116 | 0.000000000000000000e+00 117 | 0.000000000000000000e+00 118 | 0.000000000000000000e+00 119 | 0.000000000000000000e+00 120 | 0.000000000000000000e+00 121 | 1.000000000000000000e+00 122 | 1.000000000000000000e+00 123 | 1.000000000000000000e+00 124 | 1.000000000000000000e+00 125 | 1.000000000000000000e+00 126 | 0.000000000000000000e+00 127 | 0.000000000000000000e+00 128 | 0.000000000000000000e+00 129 | 0.000000000000000000e+00 130 | 0.000000000000000000e+00 131 | 0.000000000000000000e+00 132 | 0.000000000000000000e+00 133 | 0.000000000000000000e+00 134 | 0.000000000000000000e+00 135 | 1.000000000000000000e+00 136 | 1.000000000000000000e+00 137 | 1.000000000000000000e+00 138 | 1.000000000000000000e+00 139 | 1.000000000000000000e+00 140 | 0.000000000000000000e+00 141 | -------------------------------------------------------------------------------- /testdata1d_002.txt: -------------------------------------------------------------------------------- 1 | 0.000000000000000000e+00 2 | 1.000000000000000000e+00 3 | 1.000000000000000000e+00 4 | 1.000000000000000000e+00 5 | 1.000000000000000000e+00 6 | 1.000000000000000000e+00 7 | 0.000000000000000000e+00 8 | 0.000000000000000000e+00 9 | 1.000000000000000000e+00 10 | 1.000000000000000000e+00 11 | 1.000000000000000000e+00 12 | 1.000000000000000000e+00 13 | 1.000000000000000000e+00 14 | 0.000000000000000000e+00 15 | 0.000000000000000000e+00 16 | 1.000000000000000000e+00 17 | 1.000000000000000000e+00 18 | 1.000000000000000000e+00 19 | 1.000000000000000000e+00 20 | 1.000000000000000000e+00 21 | 0.000000000000000000e+00 22 | 0.000000000000000000e+00 23 | 0.000000000000000000e+00 24 | 0.000000000000000000e+00 25 | 0.000000000000000000e+00 26 | 0.000000000000000000e+00 27 | 0.000000000000000000e+00 28 | 0.000000000000000000e+00 29 | 0.000000000000000000e+00 30 | 3.300000000000000155e-01 31 | 6.600000000000000311e-01 32 | 1.000000000000000000e+00 33 | 6.600000000000000311e-01 34 | 3.300000000000000155e-01 35 | 0.000000000000000000e+00 36 | 0.000000000000000000e+00 37 | 0.000000000000000000e+00 38 | 0.000000000000000000e+00 39 | 0.000000000000000000e+00 40 | 0.000000000000000000e+00 41 | 0.000000000000000000e+00 42 | 0.000000000000000000e+00 43 | 0.000000000000000000e+00 44 | 3.300000000000000155e-01 45 | 6.600000000000000311e-01 46 | 1.000000000000000000e+00 47 | 6.600000000000000311e-01 48 | 3.300000000000000155e-01 49 | 0.000000000000000000e+00 50 | 0.000000000000000000e+00 51 | 0.000000000000000000e+00 52 | 0.000000000000000000e+00 53 | 0.000000000000000000e+00 54 | 0.000000000000000000e+00 55 | 0.000000000000000000e+00 56 | 0.000000000000000000e+00 57 | 0.000000000000000000e+00 58 | 3.300000000000000155e-01 59 | 6.600000000000000311e-01 60 | 1.000000000000000000e+00 61 | 6.600000000000000311e-01 62 | 3.300000000000000155e-01 63 | 0.000000000000000000e+00 64 | 0.000000000000000000e+00 65 | 0.000000000000000000e+00 66 | 0.000000000000000000e+00 67 | 0.000000000000000000e+00 68 | 0.000000000000000000e+00 69 | 0.000000000000000000e+00 70 | 0.000000000000000000e+00 71 | 0.000000000000000000e+00 72 | 3.300000000000000155e-01 73 | 6.600000000000000311e-01 74 | 1.000000000000000000e+00 75 | 6.600000000000000311e-01 76 | 3.300000000000000155e-01 77 | 0.000000000000000000e+00 78 | 0.000000000000000000e+00 79 | 3.300000000000000155e-01 80 | 6.600000000000000311e-01 81 | 1.000000000000000000e+00 82 | 6.600000000000000311e-01 83 | 3.300000000000000155e-01 84 | 0.000000000000000000e+00 85 | 0.000000000000000000e+00 86 | 3.300000000000000155e-01 87 | 6.600000000000000311e-01 88 | 1.000000000000000000e+00 89 | 6.600000000000000311e-01 90 | 3.300000000000000155e-01 91 | 0.000000000000000000e+00 92 | 0.000000000000000000e+00 93 | 3.300000000000000155e-01 94 | 6.600000000000000311e-01 95 | 1.000000000000000000e+00 96 | 6.600000000000000311e-01 97 | 3.300000000000000155e-01 98 | 0.000000000000000000e+00 99 | 0.000000000000000000e+00 100 | 3.300000000000000155e-01 101 | 6.600000000000000311e-01 102 | 1.000000000000000000e+00 103 | 6.600000000000000311e-01 104 | 3.300000000000000155e-01 105 | 0.000000000000000000e+00 106 | 0.000000000000000000e+00 107 | 0.000000000000000000e+00 108 | 0.000000000000000000e+00 109 | 0.000000000000000000e+00 110 | 0.000000000000000000e+00 111 | 0.000000000000000000e+00 112 | 0.000000000000000000e+00 113 | 0.000000000000000000e+00 114 | 1.000000000000000000e+00 115 | 1.000000000000000000e+00 116 | 1.000000000000000000e+00 117 | 1.000000000000000000e+00 118 | 1.000000000000000000e+00 119 | 0.000000000000000000e+00 120 | 0.000000000000000000e+00 121 | 0.000000000000000000e+00 122 | 0.000000000000000000e+00 123 | 0.000000000000000000e+00 124 | 0.000000000000000000e+00 125 | 0.000000000000000000e+00 126 | 0.000000000000000000e+00 127 | 0.000000000000000000e+00 128 | 3.300000000000000155e-01 129 | 6.600000000000000311e-01 130 | 1.000000000000000000e+00 131 | 6.600000000000000311e-01 132 | 3.300000000000000155e-01 133 | 0.000000000000000000e+00 134 | 0.000000000000000000e+00 135 | 0.000000000000000000e+00 136 | 0.000000000000000000e+00 137 | 0.000000000000000000e+00 138 | 0.000000000000000000e+00 139 | 0.000000000000000000e+00 140 | 0.000000000000000000e+00 141 | -------------------------------------------------------------------------------- /testdata1d_003.txt: -------------------------------------------------------------------------------- 1 | 0.000000000000000000e+00 2 | 1.000000000000000000e+00 3 | 1.000000000000000000e+00 4 | 1.000000000000000000e+00 5 | 1.000000000000000000e+00 6 | 1.000000000000000000e+00 7 | 0.000000000000000000e+00 8 | 0.000000000000000000e+00 9 | 1.000000000000000000e+00 10 | 1.000000000000000000e+00 11 | 1.000000000000000000e+00 12 | 1.000000000000000000e+00 13 | 1.000000000000000000e+00 14 | 0.000000000000000000e+00 15 | 0.000000000000000000e+00 16 | 0.000000000000000000e+00 17 | 0.000000000000000000e+00 18 | 0.000000000000000000e+00 19 | 0.000000000000000000e+00 20 | 0.000000000000000000e+00 21 | 0.000000000000000000e+00 22 | 0.000000000000000000e+00 23 | 3.300000000000000155e-01 24 | 6.600000000000000311e-01 25 | 1.000000000000000000e+00 26 | 6.600000000000000311e-01 27 | 3.300000000000000155e-01 28 | 0.000000000000000000e+00 29 | 0.000000000000000000e+00 30 | 3.300000000000000155e-01 31 | 6.600000000000000311e-01 32 | 1.000000000000000000e+00 33 | 6.600000000000000311e-01 34 | 3.300000000000000155e-01 35 | 0.000000000000000000e+00 36 | 0.000000000000000000e+00 37 | 3.300000000000000155e-01 38 | 6.600000000000000311e-01 39 | 1.000000000000000000e+00 40 | 6.600000000000000311e-01 41 | 3.300000000000000155e-01 42 | 0.000000000000000000e+00 43 | 0.000000000000000000e+00 44 | 0.000000000000000000e+00 45 | 0.000000000000000000e+00 46 | 0.000000000000000000e+00 47 | 0.000000000000000000e+00 48 | 0.000000000000000000e+00 49 | 0.000000000000000000e+00 50 | 0.000000000000000000e+00 51 | 1.000000000000000000e+00 52 | 1.000000000000000000e+00 53 | 1.000000000000000000e+00 54 | 1.000000000000000000e+00 55 | 1.000000000000000000e+00 56 | 0.000000000000000000e+00 57 | 0.000000000000000000e+00 58 | 1.000000000000000000e+00 59 | 1.000000000000000000e+00 60 | 1.000000000000000000e+00 61 | 1.000000000000000000e+00 62 | 1.000000000000000000e+00 63 | 0.000000000000000000e+00 64 | 0.000000000000000000e+00 65 | 0.000000000000000000e+00 66 | 0.000000000000000000e+00 67 | 0.000000000000000000e+00 68 | 0.000000000000000000e+00 69 | 0.000000000000000000e+00 70 | 0.000000000000000000e+00 71 | 0.000000000000000000e+00 72 | 3.300000000000000155e-01 73 | 6.600000000000000311e-01 74 | 1.000000000000000000e+00 75 | 6.600000000000000311e-01 76 | 3.300000000000000155e-01 77 | 0.000000000000000000e+00 78 | 0.000000000000000000e+00 79 | 0.000000000000000000e+00 80 | 0.000000000000000000e+00 81 | 0.000000000000000000e+00 82 | 0.000000000000000000e+00 83 | 0.000000000000000000e+00 84 | 0.000000000000000000e+00 85 | 0.000000000000000000e+00 86 | 3.300000000000000155e-01 87 | 6.600000000000000311e-01 88 | 1.000000000000000000e+00 89 | 6.600000000000000311e-01 90 | 3.300000000000000155e-01 91 | 0.000000000000000000e+00 92 | 0.000000000000000000e+00 93 | 0.000000000000000000e+00 94 | 0.000000000000000000e+00 95 | 0.000000000000000000e+00 96 | 0.000000000000000000e+00 97 | 0.000000000000000000e+00 98 | 0.000000000000000000e+00 99 | 0.000000000000000000e+00 100 | 3.300000000000000155e-01 101 | 6.600000000000000311e-01 102 | 1.000000000000000000e+00 103 | 6.600000000000000311e-01 104 | 3.300000000000000155e-01 105 | 0.000000000000000000e+00 106 | 0.000000000000000000e+00 107 | 3.300000000000000155e-01 108 | 6.600000000000000311e-01 109 | 1.000000000000000000e+00 110 | 6.600000000000000311e-01 111 | 3.300000000000000155e-01 112 | 0.000000000000000000e+00 113 | 0.000000000000000000e+00 114 | 0.000000000000000000e+00 115 | 0.000000000000000000e+00 116 | 0.000000000000000000e+00 117 | 0.000000000000000000e+00 118 | 0.000000000000000000e+00 119 | 0.000000000000000000e+00 120 | 0.000000000000000000e+00 121 | 1.000000000000000000e+00 122 | 1.000000000000000000e+00 123 | 1.000000000000000000e+00 124 | 1.000000000000000000e+00 125 | 1.000000000000000000e+00 126 | 0.000000000000000000e+00 127 | 0.000000000000000000e+00 128 | 0.000000000000000000e+00 129 | 0.000000000000000000e+00 130 | 0.000000000000000000e+00 131 | 0.000000000000000000e+00 132 | 0.000000000000000000e+00 133 | 0.000000000000000000e+00 134 | 0.000000000000000000e+00 135 | 3.300000000000000155e-01 136 | 6.600000000000000311e-01 137 | 1.000000000000000000e+00 138 | 6.600000000000000311e-01 139 | 3.300000000000000155e-01 140 | 0.000000000000000000e+00 141 | -------------------------------------------------------------------------------- /testdata1d_004.txt: -------------------------------------------------------------------------------- 1 | 0.000000000000000000e+00 2 | 1.000000000000000000e+00 3 | 1.000000000000000000e+00 4 | 1.000000000000000000e+00 5 | 1.000000000000000000e+00 6 | 1.000000000000000000e+00 7 | 0.000000000000000000e+00 8 | 0.000000000000000000e+00 9 | 0.000000000000000000e+00 10 | 0.000000000000000000e+00 11 | 0.000000000000000000e+00 12 | 0.000000000000000000e+00 13 | 0.000000000000000000e+00 14 | 0.000000000000000000e+00 15 | 0.000000000000000000e+00 16 | 1.000000000000000000e+00 17 | 1.000000000000000000e+00 18 | 1.000000000000000000e+00 19 | 1.000000000000000000e+00 20 | 1.000000000000000000e+00 21 | 0.000000000000000000e+00 22 | 0.000000000000000000e+00 23 | 0.000000000000000000e+00 24 | 0.000000000000000000e+00 25 | 0.000000000000000000e+00 26 | 0.000000000000000000e+00 27 | 0.000000000000000000e+00 28 | 0.000000000000000000e+00 29 | 0.000000000000000000e+00 30 | 1.000000000000000000e+00 31 | 1.000000000000000000e+00 32 | 1.000000000000000000e+00 33 | 1.000000000000000000e+00 34 | 1.000000000000000000e+00 35 | 0.000000000000000000e+00 36 | 0.000000000000000000e+00 37 | 1.000000000000000000e+00 38 | 1.000000000000000000e+00 39 | 1.000000000000000000e+00 40 | 1.000000000000000000e+00 41 | 1.000000000000000000e+00 42 | 0.000000000000000000e+00 43 | 0.000000000000000000e+00 44 | 0.000000000000000000e+00 45 | 0.000000000000000000e+00 46 | 0.000000000000000000e+00 47 | 0.000000000000000000e+00 48 | 0.000000000000000000e+00 49 | 0.000000000000000000e+00 50 | 0.000000000000000000e+00 51 | 1.000000000000000000e+00 52 | 1.000000000000000000e+00 53 | 1.000000000000000000e+00 54 | 1.000000000000000000e+00 55 | 1.000000000000000000e+00 56 | 0.000000000000000000e+00 57 | 0.000000000000000000e+00 58 | 0.000000000000000000e+00 59 | 0.000000000000000000e+00 60 | 0.000000000000000000e+00 61 | 0.000000000000000000e+00 62 | 0.000000000000000000e+00 63 | 0.000000000000000000e+00 64 | 0.000000000000000000e+00 65 | 1.000000000000000000e+00 66 | 1.000000000000000000e+00 67 | 1.000000000000000000e+00 68 | 1.000000000000000000e+00 69 | 1.000000000000000000e+00 70 | 0.000000000000000000e+00 71 | 0.000000000000000000e+00 72 | 1.000000000000000000e+00 73 | 1.000000000000000000e+00 74 | 1.000000000000000000e+00 75 | 1.000000000000000000e+00 76 | 1.000000000000000000e+00 77 | 0.000000000000000000e+00 78 | 0.000000000000000000e+00 79 | 0.000000000000000000e+00 80 | 0.000000000000000000e+00 81 | 0.000000000000000000e+00 82 | 0.000000000000000000e+00 83 | 0.000000000000000000e+00 84 | 0.000000000000000000e+00 85 | 0.000000000000000000e+00 86 | 3.300000000000000155e-01 87 | 6.600000000000000311e-01 88 | 1.000000000000000000e+00 89 | 6.600000000000000311e-01 90 | 3.300000000000000155e-01 91 | 0.000000000000000000e+00 92 | 0.000000000000000000e+00 93 | 0.000000000000000000e+00 94 | 0.000000000000000000e+00 95 | 0.000000000000000000e+00 96 | 0.000000000000000000e+00 97 | 0.000000000000000000e+00 98 | 0.000000000000000000e+00 99 | 0.000000000000000000e+00 100 | 1.000000000000000000e+00 101 | 1.000000000000000000e+00 102 | 1.000000000000000000e+00 103 | 1.000000000000000000e+00 104 | 1.000000000000000000e+00 105 | 0.000000000000000000e+00 106 | 0.000000000000000000e+00 107 | 1.000000000000000000e+00 108 | 1.000000000000000000e+00 109 | 1.000000000000000000e+00 110 | 1.000000000000000000e+00 111 | 1.000000000000000000e+00 112 | 0.000000000000000000e+00 113 | 0.000000000000000000e+00 114 | 1.000000000000000000e+00 115 | 1.000000000000000000e+00 116 | 1.000000000000000000e+00 117 | 1.000000000000000000e+00 118 | 1.000000000000000000e+00 119 | 0.000000000000000000e+00 120 | 0.000000000000000000e+00 121 | 1.000000000000000000e+00 122 | 1.000000000000000000e+00 123 | 1.000000000000000000e+00 124 | 1.000000000000000000e+00 125 | 1.000000000000000000e+00 126 | 0.000000000000000000e+00 127 | 0.000000000000000000e+00 128 | 1.000000000000000000e+00 129 | 1.000000000000000000e+00 130 | 1.000000000000000000e+00 131 | 1.000000000000000000e+00 132 | 1.000000000000000000e+00 133 | 0.000000000000000000e+00 134 | 0.000000000000000000e+00 135 | 1.000000000000000000e+00 136 | 1.000000000000000000e+00 137 | 1.000000000000000000e+00 138 | 1.000000000000000000e+00 139 | 1.000000000000000000e+00 140 | 0.000000000000000000e+00 141 | -------------------------------------------------------------------------------- /GaussianProcess.pyx: -------------------------------------------------------------------------------- 1 | # encoding: utf8 2 | from __future__ import unicode_literals 3 | import numpy as np 4 | import random 5 | import matplotlib.mlab as mlab 6 | import cython 7 | import math 8 | 9 | 10 | cdef extern from "math.h": 11 | double exp(double) 12 | double sqrt(double) 13 | double log(double) 14 | 15 | 16 | cdef class GP: 17 | cdef int ns 18 | cdef double[:] xt, yt 19 | cdef double[:,:] i_cov 20 | cdef double[:] param 21 | cdef dict param_cache 22 | 23 | cdef double beta 24 | cdef double theta0 25 | cdef double theta1 26 | cdef double theta2 27 | cdef double theta3 28 | 29 | cdef double covariance_func(self, double xi, double xj): 30 | return self.theta0 * exp(-0.5 * self.theta1 * (xi - xj) * (xi - xj)) + self.theta2 + self.theta3 * xi * xj 31 | 32 | cdef double normpdf(self, double x, double mu, double sigma): 33 | return 1./(sqrt(2*np.pi)*sigma)*exp(-0.5 * ((x - mu)/sigma)**2) 34 | 35 | def __init__( self ): 36 | self.param_cache = {} 37 | 38 | self.beta = 10.0 39 | self.theta0 = 1.0 40 | self.theta1 = 1.0 41 | self.theta2 = 0 42 | self.theta3 = 16.0 43 | 44 | 45 | cpdef learn(self, double[:] xt, double[:] yt, double[:,:] i_cov=None ): 46 | cdef int i,j 47 | cdef double c 48 | self.xt = np.array( xt ) 49 | self.yt = np.array( yt ) 50 | self.ns = len(xt) 51 | cdef double[:,:] cov = np.zeros((self.ns, self.ns)) 52 | 53 | if i_cov==None: 54 | for i in range(self.ns): 55 | for j in range(i+1): 56 | c = self.covariance_func(xt[i], xt[j]) 57 | cov[i,j] = c 58 | cov[j,i] = c 59 | if i==j: 60 | cov[i,j] += 1/self.beta 61 | 62 | 63 | #self.i_cov = np.linalg.inv(cov) 64 | # 高速化:方程式 cov * x = e の解は x = i_cov * e = i_cov になることを利用 65 | self.i_cov = np.linalg.solve(cov, np.identity(self.ns)) 66 | else: 67 | self.i_cov = i_cov 68 | self.param = np.dot(self.i_cov, self.yt) 69 | 70 | self.param_cache.clear() 71 | 72 | return self.i_cov 73 | 74 | 75 | cpdef predict( self, double[:] x ): 76 | cdef int k, i 77 | cdef double mu, sigma, c 78 | cdef int N = x.shape[0] 79 | cdef double[:] v 80 | cdef double[:] tt = self.yt #[y - np.random.normal() / self.beta for y in self.yt] 81 | cdef double[:] mus = np.zeros( N ) 82 | cdef double[:] sigmas = np.zeros(N) 83 | 84 | for k in range(N): 85 | v = np.zeros((self.ns)) 86 | for i in range(self.ns): 87 | v[i] = self.covariance_func(x[k], self.xt[i]) 88 | c = self.covariance_func(x[k], x[k]) + 1.0 / self.beta 89 | 90 | mus[k] = np.dot(v, np.dot(self.i_cov, tt)) 91 | sigmas[k] = c - np.dot(v, np.dot(self.i_cov, v)) 92 | 93 | return mus, sigmas 94 | 95 | cpdef double calc_lik( self, double[:] xs, double[:] ys ): 96 | cdef int k,i 97 | cdef int n = len(xs) 98 | cdef double lik = 0 99 | cdef int ns = self.ns 100 | cdef double c,p,mu,sigma 101 | cdef double[:] v= np.zeros((ns)) 102 | 103 | for k in range(n): 104 | # 計算結果をキャッシュして使い回す 105 | if xs[k] in self.param_cache: 106 | mu, sigma = self.param_cache[ xs[k] ] 107 | else: 108 | v = np.zeros((ns)) 109 | for i in range(ns): 110 | v[i] = self.covariance_func(xs[k], self.xt[i]) 111 | c = self.covariance_func(xs[k], xs[k]) + 1.0 / self.beta 112 | mu = np.dot(v, self.param) 113 | sigma = c - np.dot(v, np.dot(self.i_cov, v)) 114 | 115 | self.param_cache[ xs[k] ] = (mu, sigma) 116 | 117 | p = self.normpdf( ys[k] , mu, sigma ) 118 | if p<=0: 119 | p = 0.000000000001 120 | lik += log( p ) 121 | 122 | return lik 123 | 124 | cpdef estimate_hyperparams(self, int niter, double step=0.2): 125 | cdef int itr, d 126 | cdef double init_lik = self.calc_lik( self.xt, self.yt ) 127 | cdef double max_lik = init_lik 128 | cdef double old_lik = init_lik 129 | 130 | max_params = [self.beta, self.theta0, self.theta1, self.theta2, self.theta3] 131 | new_params = [self.beta, self.theta0, self.theta1, self.theta2, self.theta3] 132 | 133 | for itr in range(niter): 134 | 135 | for d in range(5): 136 | old_params = [self.beta, self.theta0, self.theta1, self.theta2, self.theta3] 137 | 138 | # 対数空間でランダムに動かす 139 | # p' = exp( log(p) + rand ) 140 | new_params[d] = old_params[d] * exp (step * random.gauss(0,1)) 141 | 142 | # 新しいパラメータで学習・尤度計算 143 | self.beta, self.theta0, self.theta1, self.theta2, self.theta3 = new_params 144 | self.learn(self.xt, self.yt) 145 | new_lik = self.calc_lik(self.xt, self.yt) 146 | 147 | 148 | # accept or reject 149 | if math.exp(new_lik-old_lik)>random.random(): 150 | # acceptの場合は更新 151 | old_lik = new_lik 152 | else: 153 | # rejectの場合は元に戻す 154 | self.beta, self.theta0, self.theta1, self.theta2, self.theta3 = old_params 155 | 156 | # 最大のものを保存する 157 | if max_lik", max_lik) 163 | return 164 | 165 | 166 | 167 | 168 | if __name__=='__main__': 169 | pass -------------------------------------------------------------------------------- /testdata2d_003.txt: -------------------------------------------------------------------------------- 1 | -3.111135099999999890e-02 -3.473816529999999569e-01 2 | -7.035613999999999930e-03 -3.491492310000000043e-01 3 | -7.346527000000000265e-03 -3.580393070000000288e-01 4 | -1.477733600000000029e-02 -3.587836909999999602e-01 5 | -6.227897300000000136e-02 -3.551517029999999853e-01 6 | -7.336360899999999630e-02 -3.488982540000000188e-01 7 | -3.901099399999999329e-02 -2.678013609999999600e-01 8 | -5.797146610000000200e-01 2.891194760000000419e-01 9 | -6.633940430000000443e-01 3.895766600000000190e-01 10 | -6.422001950000000292e-01 3.978388059999999893e-01 11 | -5.825264279999999850e-01 4.049543760000000048e-01 12 | -3.443146669999999632e-01 6.896962700000000557e-02 13 | -1.426434169999999946e-01 -2.397765960000000085e-01 14 | -9.591032400000000513e-02 -3.279843440000000387e-01 15 | -9.449494900000000863e-02 -2.988979489999999961e-01 16 | -1.385105739999999974e-01 -2.786254880000000322e-01 17 | -1.359425809999999790e-01 -3.153476559999999762e-01 18 | -6.847296099999999885e-02 -1.914549409999999896e-01 19 | -8.700408199999999648e-02 -3.245302119999999846e-01 20 | -9.418646999999999436e-02 -3.566937260000000443e-01 21 | -9.081990100000000843e-02 -3.852408139999999870e-01 22 | -8.946076999999999502e-02 8.514420300000000164e-02 23 | -9.535130299999999837e-02 3.495193479999999520e-01 24 | -1.127117920000000051e-01 3.381692809999999882e-01 25 | -1.111977160000000020e-01 6.265919000000000003e-03 26 | -1.241943890000000023e-01 -3.102540890000000107e-01 27 | -1.212624129999999995e-01 -2.571200260000000015e-01 28 | -1.397381739999999928e-01 -3.769187199999999432e-02 29 | -2.024769899999999956e-01 4.165495000000000170e-01 30 | -1.257387080000000046e-01 8.416186519999999671e-01 31 | -1.363764650000000023e-01 8.632558590000000143e-01 32 | -1.621821750000000117e-01 8.373692630000000303e-01 33 | -1.777382969999999895e-01 6.745587160000000582e-01 34 | -1.741256260000000056e-01 2.585342409999999980e-01 35 | -1.179713129999999943e-01 -1.492591250000000203e-01 36 | -8.514367700000000094e-02 -3.231830439999999749e-01 37 | -8.208051299999999384e-02 -3.169010930000000226e-01 38 | -2.145980529999999831e-01 -1.289174649999999811e-01 39 | -4.824112549999999833e-01 2.007301330000000050e-01 40 | -6.505350340000000120e-01 3.416790160000000021e-01 41 | -6.870162350000000862e-01 3.465845029999999882e-01 42 | -6.477821040000000252e-01 3.324637450000000327e-01 43 | -3.383677979999999974e-01 -8.383376999999999149e-03 44 | -1.109114759999999950e-01 -2.781143799999999944e-01 45 | -9.101392399999999605e-02 -3.293765869999999985e-01 46 | -2.307239070000000059e-01 -1.148476869999999900e-01 47 | -5.411416629999999950e-01 2.840761410000000042e-01 48 | -6.467593990000000126e-01 3.798273620000000017e-01 49 | -6.653462520000000824e-01 3.698031619999999631e-01 50 | -6.777503659999999375e-01 3.531977230000000190e-01 51 | -5.757413330000000773e-01 2.650345459999999820e-01 52 | -3.474464419999999665e-01 4.093140799999999552e-02 53 | -1.469064639999999866e-01 -2.532706450000000165e-01 54 | -7.926829499999998863e-02 -3.326917110000000011e-01 55 | -9.079827899999999563e-02 -2.117300109999999957e-01 56 | -1.016152950000000083e-01 3.445223690000000505e-01 57 | -1.495824279999999895e-01 7.762097780000000169e-01 58 | -1.613017120000000137e-01 8.654661250000000861e-01 59 | -1.774280400000000091e-01 8.719541020000000087e-01 60 | -1.609495850000000061e-01 6.150511469999999647e-01 61 | -2.728228759999999919e-01 1.648245850000000234e-01 62 | -2.719260860000000113e-01 -1.228217470000000089e-01 63 | -2.052654420000000202e-01 -3.453218799999999838e-02 64 | -1.302722320000000156e-01 1.731389310000000237e-01 65 | -7.306416299999998754e-02 3.242180179999999967e-01 66 | -7.513525399999999854e-02 2.776155399999999940e-01 67 | -9.283157300000000056e-02 -1.235776979999999997e-01 68 | -7.582263899999999723e-02 -3.038010859999999980e-01 69 | -1.580659029999999798e-01 -1.657004239999999851e-01 70 | -4.838588560000000038e-01 1.853826599999999769e-01 71 | -6.656669309999999617e-01 3.198656009999999994e-01 72 | -6.910531009999999474e-01 3.424418029999999891e-01 73 | -7.012178959999999517e-01 3.334528500000000228e-01 74 | -5.449471439999999944e-01 1.881860499999999936e-01 75 | -4.525738529999999704e-01 -8.991102600000000500e-02 76 | -3.485567019999999960e-01 -2.355810090000000079e-01 77 | -2.638355099999999953e-01 -3.169271850000000001e-01 78 | -3.765402829999999756e-01 -2.270920720000000059e-01 79 | -3.749334410000000339e-01 -1.406160280000000040e-01 80 | -6.413997799999999749e-01 9.158840899999999563e-02 81 | -6.746943970000000013e-01 3.213901670000000044e-01 82 | -6.433056639999999993e-01 2.974556270000000002e-01 83 | -4.465213009999999816e-01 8.993825499999999473e-02 84 | -3.708167110000000211e-01 -1.665457609999999866e-01 85 | -2.838018800000000064e-01 -2.798495480000000035e-01 86 | -2.124367829999999902e-01 -3.377694090000000204e-01 87 | -4.914389039999999542e-01 -9.445576499999999709e-02 88 | -6.942122800000000149e-01 1.442423860000000002e-01 89 | -6.439477540000000388e-01 2.747274780000000249e-01 90 | -4.554730220000000052e-01 8.569866199999999490e-02 91 | -1.933465270000000180e-01 -1.961325530000000150e-01 92 | -7.336734000000000311e-02 -3.090815430000000141e-01 93 | -7.925723299999999638e-02 -2.570471800000000417e-01 94 | -8.697098500000000065e-02 -3.095509029999999884e-01 95 | -8.331274399999999414e-02 -3.444990839999999555e-01 96 | -8.240383099999999683e-02 -2.147874150000000093e-01 97 | -8.530966200000000832e-02 -3.387281489999999784e-01 98 | -8.658998099999999642e-02 -3.681126100000000068e-01 99 | -8.105721300000000296e-02 -3.858922119999999567e-01 100 | -7.701063499999999395e-02 -3.844476319999999836e-01 101 | -3.556339720000000204e-01 -1.117854610000000026e-01 102 | -6.610523680000000013e-01 8.835853600000000141e-02 103 | -6.795908200000000399e-01 2.628287349999999800e-01 104 | -5.961065059999999249e-01 2.482235720000000034e-01 105 | -5.319569699999999735e-01 -7.685201299999999680e-02 106 | -4.053849489999999944e-01 -2.388018800000000219e-01 107 | -3.053603520000000016e-01 -3.182197269999999523e-01 108 | -2.352531130000000137e-01 -3.515315860000000070e-01 109 | -6.133816530000000267e-01 1.508422100000000009e-02 110 | -7.049158330000000472e-01 1.894379580000000174e-01 111 | -6.669346919999999956e-01 2.554189450000000083e-01 112 | -3.857572329999999772e-01 -2.285259999999999722e-02 113 | -1.218708270000000010e-01 -2.713391110000000217e-01 114 | -5.932222000000000189e-02 -3.083085940000000469e-01 115 | -6.214809000000000305e-02 -2.814848019999999784e-01 116 | -8.141452799999999990e-02 -2.918108520000000095e-01 117 | -7.710728499999999763e-02 -3.297678220000000437e-01 118 | -6.902033999999999947e-02 -8.282254000000000005e-02 119 | -1.031729890000000066e-01 -1.878082000000000102e-03 120 | -1.047155840000000004e-01 -2.806134640000000346e-01 121 | -9.812023200000000167e-02 -3.178023989999999577e-01 122 | -9.432597400000000687e-02 -1.231051559999999934e-01 123 | -1.445091860000000117e-01 2.257827299999999870e-01 124 | -1.110368650000000124e-01 3.225634769999999873e-01 125 | -1.184175110000000031e-01 3.329831850000000149e-01 126 | -1.471589969999999858e-01 1.309142299999999925e-01 127 | -1.116869199999999951e-01 -2.625475460000000205e-01 128 | -9.849150099999999519e-02 -3.415336609999999884e-01 129 | -1.046639790000000042e-01 -3.030157470000000020e-01 130 | -1.677001040000000165e-01 9.824249300000000018e-02 131 | -1.781740880000000082e-01 6.119255369999999639e-01 132 | -1.456141200000000135e-01 8.369074709999999584e-01 133 | -1.478971249999999904e-01 8.695234380000000929e-01 134 | -1.739361419999999880e-01 7.932427370000000311e-01 135 | -1.959444120000000122e-01 4.389043579999999944e-01 136 | -1.868013610000000269e-01 7.646980300000000286e-02 137 | -9.847186299999999282e-02 -3.442846369999999490e-01 138 | -1.016041259999999891e-01 -3.251254880000000180e-01 139 | -1.072007140000000025e-01 -1.633835750000000031e-01 140 | -8.984959399999999097e-02 -2.505507350000000244e-01 141 | -7.712214700000000200e-02 -3.052619629999999695e-01 142 | -8.001774600000000071e-02 -9.376185599999999065e-02 143 | -8.372979700000000858e-02 -4.008215299999999537e-02 144 | -1.076574250000000010e-01 -3.025905150000000043e-01 145 | -1.018541950000000085e-01 -3.470747069999999823e-01 146 | -1.044037859999999984e-01 -2.165032650000000003e-01 147 | -1.076613459999999911e-01 1.866650089999999929e-01 148 | -1.029152680000000042e-01 2.871017759999999752e-01 149 | -9.891896099999999969e-02 1.329639740000000125e-01 150 | -1.035446319999999976e-01 -8.431466699999999592e-02 151 | -1.975746149999999812e-01 -1.918123019999999901e-01 152 | -5.653860469999999472e-01 2.419727629999999796e-01 153 | -6.942432859999999595e-01 3.391022639999999866e-01 154 | -6.824299320000000169e-01 3.335856319999999653e-01 155 | -5.735889280000000534e-01 1.862561650000000013e-01 156 | -3.939237979999999917e-01 8.164764400000000533e-02 157 | -3.589823610000000276e-01 7.026092500000000185e-02 158 | -------------------------------------------------------------------------------- /testdata2d_004.txt: -------------------------------------------------------------------------------- 1 | -8.037434400000000034e-02 -3.343816219999999895e-01 2 | -8.746797900000000126e-02 -3.390204159999999911e-01 3 | -8.526770799999999761e-02 -3.449205320000000019e-01 4 | -7.627539799999999426e-02 -3.339979860000000245e-01 5 | -8.252984600000000392e-02 -3.373013609999999662e-01 6 | -8.013137100000000679e-02 -3.374427489999999863e-01 7 | -7.882665299999999653e-02 -3.327577509999999905e-01 8 | -1.707870639999999884e-01 -2.281056059999999885e-01 9 | -5.036695860000000025e-01 1.381038210000000155e-01 10 | -6.423543089999999012e-01 3.510704960000000097e-01 11 | -6.623569340000000638e-01 3.576570430000000078e-01 12 | -5.904772950000000131e-01 2.884445499999999662e-01 13 | -3.170176389999999622e-01 -5.866101099999999902e-02 14 | -8.194746399999999764e-02 -3.119230649999999994e-01 15 | -7.486127500000000490e-02 -2.253031159999999977e-01 16 | -9.690217599999999265e-02 1.665111689999999867e-01 17 | -8.146023599999999143e-02 3.208957820000000183e-01 18 | -9.227140799999999921e-02 2.779565119999999889e-01 19 | -1.118692470000000050e-01 -1.462664790000000048e-01 20 | -9.598220100000000310e-02 -3.223974609999999963e-01 21 | -1.145008090000000089e-01 -1.041645280000000062e-01 22 | -1.664497379999999860e-01 5.881971440000000051e-01 23 | -1.489059140000000003e-01 8.364544680000000065e-01 24 | -1.711142429999999992e-01 8.851972660000000381e-01 25 | -1.740132600000000029e-01 7.082664789999999488e-01 26 | -1.207070920000000019e-01 1.103561549999999974e-01 27 | -1.000039369999999872e-01 2.007525180000000187e-01 28 | -1.551104280000000224e-01 -1.490721899999999933e-02 29 | -1.440225069999999941e-01 -1.040046300000000042e-02 30 | -1.326144099999999881e-01 -1.631389470000000064e-01 31 | -5.416975710000000444e-01 7.046432000000000043e-03 32 | -6.821477049999999931e-01 1.971261749999999868e-01 33 | -4.261848140000000229e-01 1.049677580000000082e-01 34 | -1.341661530000000102e-01 -2.560378420000000155e-01 35 | -7.628583500000001016e-02 -3.128277890000000228e-01 36 | -1.047543950000000001e-01 -2.870844120000000110e-01 37 | -1.000536120000000001e-01 -3.329063110000000103e-01 38 | -1.674651949999999834e-01 1.521235049999999922e-01 39 | -2.176510929999999899e-01 7.449967040000000651e-01 40 | -1.701752169999999897e-01 8.784956670000000356e-01 41 | -1.801566160000000194e-01 8.379150389999999726e-01 42 | -1.778352049999999962e-01 5.134660639999999443e-01 43 | -1.105577699999999997e-01 -1.103297419999999945e-01 44 | -9.039992499999999209e-02 -3.105708309999999917e-01 45 | -1.055370639999999999e-01 -2.886206670000000529e-01 46 | -1.883921809999999919e-01 -2.990462039999999821e-01 47 | -4.170594479999999993e-01 -6.223838799999999866e-02 48 | -6.665136720000000015e-01 1.491964110000000010e-01 49 | -6.167758790000000824e-01 3.560812990000000178e-01 50 | -3.758467409999999842e-01 7.707563800000000187e-02 51 | -1.199264909999999962e-01 -2.359030000000000016e-01 52 | -9.628041799999999262e-02 -2.487023619999999824e-01 53 | -9.074296599999999435e-02 5.003300100000000056e-02 54 | -6.705191800000000202e-02 3.168568729999999833e-01 55 | -5.925526399999999499e-02 3.386675420000000436e-01 56 | -5.968873599999999918e-02 3.161091919999999833e-01 57 | -9.591075899999999821e-02 -1.097985529999999932e-01 58 | -9.283778399999999265e-02 -3.242775880000000055e-01 59 | -9.535301200000000088e-02 -3.567096859999999703e-01 60 | -2.084322510000000128e-01 -9.245355200000000828e-02 61 | -4.163558649999999917e-01 2.316207730000000020e-01 62 | -6.464862670000000033e-01 3.646270449999999830e-01 63 | -6.735954589999999520e-01 3.397711179999999831e-01 64 | -5.592611690000000024e-01 2.937575679999999689e-01 65 | -2.325986479999999912e-01 -8.984158300000000263e-02 66 | -9.789936800000000050e-02 -2.845228579999999896e-01 67 | -7.334813699999999381e-02 -3.271892089999999809e-01 68 | -2.001859279999999852e-01 -1.097090149999999931e-01 69 | -4.809586790000000001e-01 2.908498540000000188e-01 70 | -6.305190430000000568e-01 3.961860050000000077e-01 71 | -6.583934940000000235e-01 3.962358400000000058e-01 72 | -6.825717770000000462e-01 3.800404659999999657e-01 73 | -5.078769530000000199e-01 2.502407070000000067e-01 74 | -2.319479980000000163e-01 -1.096969450000000040e-01 75 | -8.689703400000001188e-02 -3.086182860000000194e-01 76 | -8.846842200000000489e-02 -2.819821779999999722e-01 77 | -9.512851699999999577e-02 5.746070899999999870e-02 78 | -8.849082199999999676e-02 2.713534550000000212e-01 79 | -9.027497900000000519e-02 3.096023559999999675e-01 80 | -1.207915729999999993e-01 2.692555239999999683e-01 81 | -1.203226850000000125e-01 -9.772338899999999384e-02 82 | -1.050971909999999926e-01 -3.310082400000000091e-01 83 | -1.067433700000000041e-01 -2.766129149999999592e-01 84 | -6.278036900000000253e-02 -3.455460820000000322e-01 85 | -5.799277500000000335e-02 -3.633811650000000060e-01 86 | -1.573978729999999937e-01 4.073471979999999659e-01 87 | -1.480465390000000048e-01 7.127734989999999771e-01 88 | -1.559405819999999943e-01 1.225226900000000035e-01 89 | -1.054765629999999954e-01 -2.878988040000000082e-01 90 | -9.235263800000000078e-02 -3.394879760000000246e-01 91 | -6.075701099999999966e-02 -2.609009399999999701e-01 92 | -1.185661240000000088e-01 -2.901998599999999762e-01 93 | -5.376812739999999868e-01 1.944544200000000028e-02 94 | -6.986362919999999921e-01 2.187337339999999852e-01 95 | -6.801400149999999867e-01 3.423609619999999909e-01 96 | -5.319823000000000190e-01 1.643605499999999942e-01 97 | -2.703277889999999850e-01 -1.536215819999999788e-01 98 | -1.175011669999999897e-01 -2.957901000000000002e-01 99 | -1.975231630000000016e-01 -1.401091770000000014e-01 100 | -4.683012079999999688e-01 1.845561370000000090e-01 101 | -6.437977289999999853e-01 3.791493530000000223e-01 102 | -6.654316409999999626e-01 3.492452090000000009e-01 103 | -6.681678470000000925e-01 3.579955140000000147e-01 104 | -5.621369019999999939e-01 2.273214419999999847e-01 105 | -2.996140750000000352e-01 -9.738053100000000628e-02 106 | -1.087129520000000016e-01 -3.086604000000000014e-01 107 | -1.359727780000000164e-01 -1.465050050000000215e-01 108 | -1.233460160000000028e-01 2.651038820000000129e-01 109 | -1.060893779999999981e-01 3.036113889999999538e-01 110 | -1.406415099999999974e-01 2.304472959999999959e-01 111 | -1.430781250000000004e-01 -1.526909000000000122e-03 112 | -1.336953280000000022e-01 -1.529046940000000077e-01 113 | -1.204661709999999969e-01 -2.619636540000000458e-01 114 | -1.388961489999999965e-01 -2.206705780000000061e-01 115 | -1.141737059999999998e-01 -2.866005860000000460e-01 116 | -1.152095790000000064e-01 -2.672063100000000163e-02 117 | -1.314533230000000108e-01 -2.416840000000000123e-04 118 | -1.025079120000000066e-01 -2.947850949999999970e-01 119 | -9.764334100000000849e-02 -3.414722290000000160e-01 120 | -1.038711320000000049e-01 -3.018163150000000017e-01 121 | -1.275019910000000090e-01 -1.696509090000000164e-01 122 | -1.081394959999999877e-01 -2.581088260000000134e-01 123 | -9.122975200000001117e-02 -3.142473139999999998e-01 124 | -8.540406799999999965e-02 -3.540638119999999778e-01 125 | -1.092358090000000032e-01 -2.692007140000000076e-01 126 | -1.296940609999999994e-01 -2.456434480000000142e-01 127 | -1.171421890000000077e-01 -3.290770869999999904e-01 128 | -1.323823240000000234e-01 -2.616612549999999815e-01 129 | -1.566124880000000219e-01 -3.682193800000000544e-02 130 | -1.249707869999999998e-01 2.583791810000000133e-01 131 | -1.166607439999999968e-01 3.350938719999999593e-01 132 | -1.249822010000000011e-01 3.396535640000000189e-01 133 | -1.137065349999999975e-01 2.376489870000000060e-01 134 | -1.437905270000000013e-01 -3.870157600000000142e-02 135 | -1.200281370000000070e-01 -3.137123720000000171e-01 136 | -1.236463169999999917e-01 -3.362706299999999593e-01 137 | -1.321963959999999938e-01 -3.313629460000000471e-01 138 | -3.666185299999999980e-01 -9.724789400000000139e-02 139 | -6.708327640000000258e-01 1.118729859999999937e-01 140 | -6.722050779999999559e-01 3.073613590000000007e-01 141 | -5.782796629999999993e-01 2.764669190000000332e-01 142 | -4.990268549999999914e-01 -4.293115200000000020e-02 143 | -3.788558959999999698e-01 -2.232847899999999830e-01 144 | -2.914663699999999746e-01 -1.180124440000000080e-01 145 | -2.748660889999999801e-01 -2.352367399999999997e-01 146 | -2.072704770000000085e-01 -3.033035279999999889e-01 147 | -1.587235260000000037e-01 -1.553090359999999837e-01 148 | -1.404776309999999917e-01 -4.890901199999999477e-02 149 | -1.132853320000000025e-01 -2.960292969999999690e-01 150 | -1.036594539999999981e-01 -3.677675169999999882e-01 151 | -9.905702200000000845e-02 -3.634746090000000041e-01 152 | -1.103141399999999911e-01 -2.241923370000000193e-01 153 | -1.235339810000000010e-01 8.057208999999999899e-02 154 | -1.044704590000000016e-01 2.967948610000000209e-01 155 | -9.892718500000000081e-02 3.357475590000000287e-01 156 | -1.166499330000000112e-01 2.764873660000000122e-01 157 | -1.571702879999999913e-01 6.085853999999999916e-03 158 | -1.452110749999999950e-01 -1.611322330000000136e-01 159 | -1.345248410000000061e-01 -2.687993159999999548e-01 160 | -1.264550700000000028e-01 -3.306890869999999927e-01 161 | -------------------------------------------------------------------------------- /testdata2d_000.txt: -------------------------------------------------------------------------------- 1 | -1.274970400000000059e-01 -3.301310419999999857e-01 2 | -1.174420549999999897e-01 -3.304050290000000167e-01 3 | -1.058545070000000005e-01 -3.328387449999999914e-01 4 | -1.037170720000000074e-01 -3.333381959999999755e-01 5 | -1.145601499999999995e-01 -3.345429380000000119e-01 6 | -1.233602599999999994e-01 -3.322131350000000483e-01 7 | -1.209214019999999973e-01 -3.288552250000000288e-01 8 | -1.073263019999999984e-01 -3.305723879999999948e-01 9 | -1.143754959999999932e-01 -2.943729549999999917e-01 10 | -1.557018280000000143e-01 4.803545399999999826e-02 11 | -1.804318079999999991e-01 3.711787409999999787e-01 12 | -1.821453400000000167e-01 4.111394649999999817e-01 13 | -1.891637879999999994e-01 3.698441769999999962e-01 14 | -1.829860530000000096e-01 -1.709681099999999995e-02 15 | -1.759605099999999867e-01 -3.061334529999999998e-01 16 | -1.948683780000000088e-01 -9.942817700000000647e-02 17 | -2.051589970000000096e-01 6.362719730000000462e-01 18 | -2.119207150000000095e-01 8.452341309999999996e-01 19 | -2.857781070000000034e-01 6.125905760000001088e-01 20 | -2.286484380000000094e-01 2.237238920000000075e-01 21 | -2.190800629999999916e-01 1.895609890000000131e-01 22 | -1.893415070000000200e-01 3.335488500000000078e-02 23 | -1.870517429999999925e-01 2.717629999999999768e-01 24 | -1.573805240000000216e-01 3.712073359999999989e-01 25 | -1.663415530000000031e-01 3.793665769999999826e-01 26 | -1.913890230000000192e-01 2.559565280000000165e-01 27 | -2.006497500000000156e-01 1.120467069999999954e-01 28 | -1.993409730000000046e-01 -6.532015199999999244e-02 29 | -4.283095089999999772e-01 9.193404400000000642e-02 30 | -7.176795650000000748e-01 1.917237090000000199e-01 31 | -6.131892700000000085e-01 1.803932040000000014e-01 32 | -4.765294800000000053e-01 4.291872399999999838e-02 33 | -4.217670900000000112e-01 3.498673999999999534e-02 34 | -4.268585209999999908e-01 2.638649399999999992e-02 35 | -6.648334350000000281e-01 2.461288759999999964e-01 36 | -6.942517089999999946e-01 2.752344360000000267e-01 37 | -6.621058960000000271e-01 2.201535800000000154e-01 38 | -4.259789119999999873e-01 -7.003605699999999878e-02 39 | -2.064499049999999891e-01 -2.904564209999999647e-01 40 | -1.567074430000000018e-01 -3.317575680000000027e-01 41 | -1.439857940000000003e-01 -3.078427730000000140e-01 42 | -1.770126190000000099e-01 1.035685650000000013e-01 43 | -1.677463379999999948e-01 3.490404049999999980e-01 44 | -1.934348599999999863e-01 3.572219850000000196e-01 45 | -2.000258179999999941e-01 -9.998857099999999831e-02 46 | -1.929382779999999908e-01 -2.357547610000000071e-01 47 | -3.404322199999999521e-01 9.762499000000000871e-03 48 | -6.640159909999999721e-01 2.555314790000000058e-01 49 | -7.062962649999999787e-01 2.412376710000000146e-01 50 | -6.867384029999999973e-01 2.534622040000000243e-01 51 | -5.047207639999999884e-01 1.183334659999999983e-01 52 | -4.238577880000000131e-01 8.414489699999999628e-02 53 | -5.955196529999999822e-01 2.560199890000000034e-01 54 | -6.947052000000000227e-01 2.687025449999999593e-01 55 | -6.934333500000000594e-01 2.744204100000000035e-01 56 | -5.560139159999999414e-01 6.838336899999999940e-02 57 | -4.134701230000000227e-01 1.865412099999999920e-02 58 | -2.955803530000000179e-01 2.729606600000000077e-02 59 | -2.414667050000000037e-01 7.141210940000000118e-01 60 | -2.415378880000000061e-01 8.357835080000000083e-01 61 | -3.067753910000000084e-01 6.371153560000000216e-01 62 | -3.144546199999999625e-01 2.388010710000000036e-01 63 | -2.766730350000000116e-01 -3.011221700000000015e-02 64 | -2.636852719999999706e-01 1.353336179999999889e-01 65 | -2.315554349999999761e-01 3.516583249999999938e-01 66 | -1.832822879999999877e-01 3.798492739999999590e-01 67 | -2.161624149999999966e-01 1.746765140000000049e-01 68 | -2.008994899999999861e-01 -2.747830809999999846e-01 69 | -2.058020630000000073e-01 -3.231492309999999812e-01 70 | -3.895888370000000211e-01 6.256437700000000435e-02 71 | -6.548101199999999400e-01 3.258110659999999825e-01 72 | -7.073006589999999427e-01 2.878812869999999857e-01 73 | -7.159788820000000387e-01 3.106031489999999673e-01 74 | -5.454666750000000119e-01 1.741965940000000101e-01 75 | -2.671849370000000112e-01 -1.813945309999999977e-01 76 | -1.590366059999999970e-01 -3.111454770000000036e-01 77 | -1.572348939999999862e-01 -2.575657959999999580e-01 78 | -1.513000489999999920e-01 -2.453317570000000114e-01 79 | -1.844647520000000096e-01 1.598980259999999987e-01 80 | -2.763004460000000329e-01 6.821360469999999676e-01 81 | -1.986812130000000232e-01 8.587027590000000377e-01 82 | -2.234732209999999997e-01 8.499990229999999647e-01 83 | -2.807887270000000157e-01 5.744732670000000097e-01 84 | -2.215849609999999970e-01 -1.038603359999999975e-01 85 | -1.771918329999999930e-01 -3.220888670000000009e-01 86 | -1.696551210000000198e-01 -3.382705690000000209e-01 87 | -4.109625550000000072e-01 -9.169598000000001026e-03 88 | -6.848391110000000559e-01 2.782072749999999761e-01 89 | -7.022815550000000018e-01 2.627289429999999926e-01 90 | -7.198509520000000439e-01 2.350362240000000158e-01 91 | -7.038298949999999277e-01 2.565833739999999752e-01 92 | -5.906330570000000169e-01 1.406563419999999898e-01 93 | -3.594371339999999915e-01 -1.126079479999999994e-01 94 | -1.784361720000000040e-01 -3.006056520000000010e-01 95 | -1.390390170000000147e-01 -3.273385010000000039e-01 96 | -1.735748599999999975e-01 -2.974168090000000042e-01 97 | -3.662218930000000205e-01 3.389481000000000178e-03 98 | -5.662825319999998941e-01 2.539985200000000054e-01 99 | -7.040274050000000505e-01 3.052837220000000351e-01 100 | -7.170801390000000053e-01 2.752038880000000076e-01 101 | -6.826856689999999395e-01 2.972750239999999988e-01 102 | -5.276466060000000180e-01 1.177268219999999949e-01 103 | -3.218136289999999899e-01 -1.010718690000000086e-01 104 | -1.810691070000000069e-01 -3.100121769999999999e-01 105 | -1.540225679999999986e-01 -3.437441709999999873e-01 106 | -2.272551730000000048e-01 -2.074757539999999845e-01 107 | -4.528975829999999925e-01 1.599538880000000163e-01 108 | -6.329063719999999948e-01 3.644258120000000156e-01 109 | -6.984758300000000197e-01 3.518879999999999786e-01 110 | -7.079435419999999812e-01 3.018754579999999854e-01 111 | -6.720590210000000342e-01 3.002053829999999923e-01 112 | -5.093158260000000270e-01 1.206030270000000015e-01 113 | -2.392960660000000017e-01 -2.221675720000000076e-01 114 | -1.462871249999999901e-01 -3.246593629999999786e-01 115 | -1.760995939999999982e-01 -2.018049619999999766e-01 116 | -2.587046809999999919e-01 2.105472719999999798e-01 117 | -2.651030269999999911e-01 7.000510249999999379e-01 118 | -2.304107360000000049e-01 8.567934569999999805e-01 119 | -2.307722170000000017e-01 8.720373540000000423e-01 120 | -2.698154910000000184e-01 8.388236079999999983e-01 121 | -3.216886899999999994e-01 5.156547849999999489e-01 122 | -2.807487489999999641e-01 -8.832698099999999886e-02 123 | -2.085703430000000191e-01 -3.320950320000000122e-01 124 | -1.959888459999999943e-01 -3.597421259999999954e-01 125 | -1.683545070000000143e-01 -3.099357910000000160e-01 126 | -1.783551030000000148e-01 6.833387000000000489e-02 127 | -1.548889159999999876e-01 3.150026859999999762e-01 128 | -1.265856399999999993e-01 3.365267940000000180e-01 129 | -1.498690799999999879e-01 3.458536990000000144e-01 130 | -1.930518189999999856e-01 6.760846700000000542e-02 131 | -1.798919830000000053e-01 -2.678617249999999950e-01 132 | -1.704776309999999906e-01 -3.458104250000000324e-01 133 | -1.659999390000000130e-01 -3.588372499999999965e-01 134 | -1.710572659999999856e-01 -3.166149899999999850e-01 135 | -1.821857909999999858e-01 1.242771610000000110e-01 136 | -1.519583280000000036e-01 3.313861690000000082e-01 137 | -1.465989839999999877e-01 3.534674380000000227e-01 138 | -1.846804050000000197e-01 2.840901490000000140e-01 139 | -1.949628449999999957e-01 -1.512051699999999999e-01 140 | -1.781608280000000211e-01 -3.348123780000000216e-01 141 | -1.774512629999999980e-01 -3.590289309999999956e-01 142 | -1.868865050000000083e-01 -3.104218750000000138e-01 143 | -2.215449680000000088e-01 7.379394499999999968e-02 144 | -2.190412750000000075e-01 5.718124390000000057e-01 145 | -1.942999569999999954e-01 8.193681640000000099e-01 146 | -1.876730959999999837e-01 8.679111330000000013e-01 147 | -1.998513180000000000e-01 8.708190310000000212e-01 148 | -2.272789150000000258e-01 8.452926029999999757e-01 149 | -2.855627440000000350e-01 6.478189699999999940e-01 150 | -3.047093810000000014e-01 2.998598020000000086e-01 151 | -2.384967349999999875e-01 -1.548172610000000116e-01 152 | -2.024429630000000035e-01 -3.445415949999999783e-01 153 | -1.967888030000000121e-01 -3.691420899999999783e-01 154 | -2.856964419999999949e-01 -2.287075959999999852e-01 155 | -4.967153320000000094e-01 6.009054600000000163e-02 156 | -6.823396000000000461e-01 2.365318150000000064e-01 157 | -7.198984380000000849e-01 2.405752720000000067e-01 158 | -7.236665039999999882e-01 2.412381440000000155e-01 159 | -6.261687620000000454e-01 1.749837489999999940e-01 160 | -3.689834589999999581e-01 -7.338745900000000211e-02 161 | -1.860852970000000106e-01 -3.062612299999999954e-01 162 | -1.338548280000000090e-01 -3.590865169999999940e-01 163 | -------------------------------------------------------------------------------- /testdata2d_001.txt: -------------------------------------------------------------------------------- 1 | 1.881630710000000151e-01 -3.300244139999999882e-01 2 | 1.887158359999999979e-01 -3.350884699999999716e-01 3 | 1.934479980000000099e-01 -3.350650629999999963e-01 4 | 1.909607090000000063e-01 -3.343394470000000118e-01 5 | 1.910723719999999903e-01 -3.346158140000000114e-01 6 | 1.969827120000000042e-01 -3.358767700000000467e-01 7 | 1.911912379999999856e-01 -3.328544309999999506e-01 8 | 1.894017939999999844e-01 -3.390273129999999968e-01 9 | 1.927159880000000047e-01 -3.403316650000000054e-01 10 | 1.912149200000000104e-01 -3.424979549999999651e-01 11 | -1.267330929999999911e-01 2.358719179999999860e-01 12 | -1.532241520000000023e-01 4.038346560000000141e-01 13 | -1.470757749999999919e-01 4.264907840000000117e-01 14 | -1.640885930000000048e-01 3.752849120000000260e-01 15 | -1.518077089999999851e-01 -8.185244799999999432e-02 16 | -1.540292659999999980e-01 -3.302635800000000010e-01 17 | -1.529353790000000102e-01 -2.738489379999999862e-01 18 | -2.093655550000000087e-01 1.170647350000000031e-01 19 | -1.805560300000000062e-01 7.419854739999999227e-01 20 | -1.670369869999999979e-01 8.413768310000000472e-01 21 | -1.982018740000000001e-01 8.219372560000000050e-01 22 | -4.097703249999999908e-01 5.643933110000000086e-01 23 | -6.089040529999999452e-01 1.589947510000000175e-01 24 | -5.512197269999999927e-01 -9.378904700000000039e-02 25 | -4.595665890000000253e-01 -2.936699000000000080e-03 26 | -4.678210450000000464e-01 8.622598300000000604e-02 27 | -6.635958859999999682e-01 3.526399230000000218e-01 28 | -7.032474370000000308e-01 3.295594179999999929e-01 29 | -6.047521970000000469e-01 3.162616879999999853e-01 30 | -3.030900270000000396e-01 -5.951832600000000334e-02 31 | -1.449431460000000227e-01 -3.036187130000000400e-01 32 | -1.210985410000000040e-01 -3.344196469999999866e-01 33 | -2.245199739999999833e-01 -2.543773799999999863e-01 34 | -5.069039309999999743e-01 2.585906370000000121e-01 35 | -6.628098139999999416e-01 3.723560180000000108e-01 36 | -6.918381350000000207e-01 3.514799189999999740e-01 37 | -6.394658810000000138e-01 3.459712520000000069e-01 38 | -3.191784670000000212e-01 -3.151561699999999577e-02 39 | -1.206052320000000067e-01 -3.099135739999999695e-01 40 | -1.189858250000000034e-01 -2.650496219999999847e-01 41 | -1.286575010000000074e-01 1.550918269999999877e-01 42 | -1.183335419999999999e-01 3.796619870000000341e-01 43 | -1.150142519999999974e-01 4.260964359999999673e-01 44 | -1.300388949999999877e-01 3.529037480000000171e-01 45 | -1.390548249999999930e-01 -7.079730200000000639e-02 46 | -1.520357509999999968e-01 -3.216704710000000134e-01 47 | -1.470632319999999882e-01 -3.465399169999999751e-01 48 | -1.815187679999999970e-01 -2.243502200000000169e-01 49 | -3.855119629999999575e-01 1.721515960000000178e-01 50 | -6.329016109999999751e-01 3.847157900000000019e-01 51 | -7.086809080000000538e-01 3.162815550000000475e-01 52 | -7.125230710000000078e-01 3.046899409999999642e-01 53 | -6.655255130000000685e-01 3.475681149999999553e-01 54 | -4.381758119999999979e-01 1.848923189999999994e-01 55 | -1.781495060000000130e-01 -1.899576869999999862e-01 56 | -1.113418810000000037e-01 -3.239902649999999995e-01 57 | -1.418902890000000028e-01 -2.732880249999999900e-01 58 | -3.746709289999999859e-01 9.468270900000000379e-02 59 | -6.313308109999999918e-01 3.543713379999999802e-01 60 | -6.776301270000000265e-01 3.703716739999999841e-01 61 | -6.884916990000000681e-01 3.525514829999999988e-01 62 | -6.451859130000000553e-01 3.268338319999999908e-01 63 | -3.590366819999999959e-01 -2.250061000000000075e-02 64 | -1.606313319999999878e-01 -2.830668949999999850e-01 65 | -1.302899630000000086e-01 -3.269798279999999724e-01 66 | -1.674967350000000077e-01 4.404429600000000361e-02 67 | -1.655772859999999902e-01 3.980592649999999955e-01 68 | -1.480332950000000092e-01 4.366979979999999761e-01 69 | -1.587965699999999980e-01 4.296082149999999600e-01 70 | -1.873310850000000083e-01 -5.346708300000000552e-02 71 | -1.952382969999999773e-01 -3.166759640000000320e-01 72 | -1.898776249999999943e-01 -2.919372559999999783e-01 73 | -1.820529940000000235e-01 1.949711150000000004e-01 74 | -1.943790440000000008e-01 4.301342770000000093e-01 75 | -1.544230959999999819e-01 4.408635559999999898e-01 76 | -1.694291689999999906e-01 4.510469969999999496e-01 77 | -1.976874390000000203e-01 3.570720210000000172e-01 78 | -2.269759369999999887e-01 -8.112018600000001078e-02 79 | -2.127815400000000190e-01 -3.161181949999999907e-01 80 | -1.913742979999999982e-01 -1.621910399999999808e-01 81 | -1.929365390000000180e-01 2.479287870000000116e-01 82 | -1.620525049999999856e-01 4.316054690000000194e-01 83 | -1.551517330000000139e-01 4.215731200000000234e-01 84 | -1.875422360000000011e-01 4.411928710000000420e-01 85 | -2.010994870000000212e-01 2.091977540000000135e-01 86 | -1.859545439999999994e-01 -2.176868440000000182e-01 87 | -1.674902500000000072e-01 -3.374871219999999727e-01 88 | -1.826586299999999885e-01 -3.068912349999999845e-01 89 | -1.875692290000000040e-01 -3.210209350000000073e-01 90 | -2.556477970000000099e-01 1.410058289999999992e-01 91 | -3.405859990000000281e-01 7.349248659999999544e-01 92 | -1.964960169999999950e-01 8.565471189999999124e-01 93 | -2.227167820000000020e-01 8.204987180000000713e-01 94 | -2.166961669999999951e-01 1.885491639999999913e-01 95 | -1.721405179999999924e-01 -2.585706180000000298e-01 96 | -1.648115229999999876e-01 -3.190648499999999554e-01 97 | -1.944972380000000167e-01 1.513537750000000237e-01 98 | -2.008808900000000064e-01 6.269545289999999271e-01 99 | -1.994383390000000200e-01 8.418299559999999904e-01 100 | -1.992694090000000084e-01 8.620614010000000604e-01 101 | -2.246284030000000043e-01 8.678308110000000353e-01 102 | -2.623507079999999880e-01 8.062860720000000203e-01 103 | -3.063422550000000077e-01 3.742312620000000090e-01 104 | -2.804031069999999848e-01 4.495974700000000129e-02 105 | -2.411742100000000000e-01 -1.480115199999999798e-01 106 | -3.864447329999999847e-01 1.134584349999999964e-01 107 | -6.279007570000000316e-01 2.806808470000000111e-01 108 | -7.079477539999999847e-01 3.484671939999999801e-01 109 | -7.200921630000000073e-01 3.308805850000000048e-01 110 | -6.419807130000000361e-01 3.054971310000000329e-01 111 | -3.327915039999999602e-01 -5.559335299999999813e-02 112 | -1.559666290000000233e-01 -3.022868040000000200e-01 113 | -1.450244599999999939e-01 -3.086147460000000509e-01 114 | -2.042602079999999987e-01 1.560706940000000098e-01 115 | -1.584006199999999920e-01 4.224393309999999735e-01 116 | -1.475872649999999953e-01 4.451903080000000346e-01 117 | -1.743230440000000103e-01 2.728343199999999635e-01 118 | -1.686834560000000094e-01 -2.217091979999999962e-01 119 | -1.877241359999999859e-01 -2.959077760000000112e-01 120 | -2.078659209999999813e-01 2.834460450000000353e-01 121 | -2.074891969999999863e-01 7.751674799999999088e-01 122 | -2.071627349999999868e-01 8.651113890000000639e-01 123 | -2.155327910000000013e-01 8.587545779999999906e-01 124 | -2.363369449999999927e-01 8.370231929999999432e-01 125 | -2.458257140000000007e-01 4.353687439999999742e-01 126 | -2.189994809999999958e-01 2.016475700000000190e-02 127 | -1.758251650000000055e-01 -2.198094939999999942e-01 128 | -2.017217099999999985e-01 1.128130799999999961e-01 129 | -2.165701449999999917e-01 6.749788210000000621e-01 130 | -1.862316440000000017e-01 8.747727660000000904e-01 131 | -1.964820100000000125e-01 8.773842160000000501e-01 132 | -2.432595670000000099e-01 8.054096680000000230e-01 133 | -2.125359039999999977e-01 1.852854460000000203e-01 134 | -1.799524690000000038e-01 -2.479250490000000084e-01 135 | -1.799603270000000033e-01 -2.870006709999999850e-01 136 | -5.018503109999999934e-01 1.414175720000000192e-01 137 | -6.736031490000000677e-01 3.712232060000000278e-01 138 | -6.961202389999999740e-01 3.555798950000000347e-01 139 | -6.977454830000000552e-01 3.602257389999999893e-01 140 | -4.382184449999999565e-01 9.371692699999999154e-02 141 | -1.555553889999999884e-01 -2.701401059999999910e-01 142 | -1.761269379999999829e-01 -2.498125609999999885e-01 143 | -1.777726440000000074e-01 2.549532170000000098e-01 144 | -1.536853940000000029e-01 4.412227479999999979e-01 145 | -1.469054260000000056e-01 4.432138059999999880e-01 146 | -1.779505160000000030e-01 3.786802979999999708e-01 147 | -1.746190489999999984e-01 -4.936005000000000253e-02 148 | -1.701038360000000083e-01 -3.052207639999999778e-01 149 | -1.620055850000000075e-01 -2.817267759999999566e-01 150 | -1.641904140000000067e-01 1.456778260000000103e-01 151 | -1.597358700000000020e-01 4.343064580000000063e-01 152 | -1.595671690000000087e-01 4.637090759999999978e-01 153 | -1.920386350000000131e-01 3.791846919999999899e-01 154 | -2.069783329999999866e-01 -2.688001999999999753e-02 155 | -1.903839720000000124e-01 -3.219703369999999953e-01 156 | -1.965913089999999919e-01 -3.072385559999999960e-01 157 | -3.746541139999999825e-01 4.208477400000000535e-02 158 | -6.168559569999999548e-01 3.440423280000000084e-01 159 | -6.977642819999999579e-01 3.723073120000000014e-01 160 | -6.995253909999999964e-01 3.260917360000000209e-01 161 | -6.917758790000000380e-01 3.431418150000000167e-01 162 | -5.382474369999999952e-01 2.262246400000000046e-01 163 | -3.860354610000000242e-01 1.403272710000000034e-01 164 | -3.626759949999999733e-01 1.241302799999999956e-01 165 | -------------------------------------------------------------------------------- /testdata2d_002.txt: -------------------------------------------------------------------------------- 1 | -1.250003199999999981e-01 -3.904392090000000093e-01 2 | -1.282566679999999903e-01 -3.979841920000000144e-01 3 | -1.280492709999999923e-01 -3.986364750000000456e-01 4 | -1.291195529999999980e-01 -3.991112059999999961e-01 5 | -1.270956950000000085e-01 -3.959719850000000263e-01 6 | -1.269400250000000119e-01 -3.964807739999999803e-01 7 | -1.289333340000000105e-01 -3.942283330000000419e-01 8 | -1.281256410000000123e-01 -3.921396480000000073e-01 9 | -1.282679599999999864e-01 -3.960485229999999857e-01 10 | -1.268429490000000104e-01 -3.968542179999999808e-01 11 | -1.209760590000000108e-01 -3.975765380000000349e-01 12 | -8.284521499999999983e-02 -2.836046599999999737e-02 13 | -1.456371919999999986e-01 5.257296139999999562e-01 14 | -1.471999209999999836e-01 8.723439939999999559e-01 15 | -1.503406679999999829e-01 8.662230220000000092e-01 16 | -1.896687320000000065e-01 8.581812739999999939e-01 17 | -1.808099669999999881e-01 5.930197139999999756e-01 18 | -1.722353520000000082e-01 1.606854400000000127e-01 19 | -1.633876340000000038e-01 -4.022373199999999815e-02 20 | -1.388310549999999810e-01 -2.454167790000000016e-01 21 | -9.924048600000000275e-02 -3.237055050000000045e-01 22 | -1.205378110000000086e-01 -2.767930909999999911e-01 23 | -1.191629490000000041e-01 2.168745000000000134e-03 24 | -1.225402599999999981e-01 3.425863040000000082e-01 25 | -1.296603550000000049e-01 3.870203549999999826e-01 26 | -1.321190190000000042e-01 2.358772739999999979e-01 27 | -1.399619899999999806e-01 -1.827551570000000014e-01 28 | -1.345468140000000146e-01 -3.356440430000000030e-01 29 | -1.341019290000000086e-01 -3.482027590000000283e-01 30 | -1.267398680000000055e-01 -1.659690249999999923e-01 31 | -1.302079469999999906e-01 -2.937833249999999841e-01 32 | -1.795289150000000111e-01 1.757906340000000012e-01 33 | -2.392007290000000008e-01 7.560876460000000021e-01 34 | -1.802421260000000025e-01 8.839628910000000284e-01 35 | -2.099056549999999965e-01 8.749831540000000407e-01 36 | -2.180164490000000010e-01 7.071697999999999595e-01 37 | -1.830686800000000114e-01 1.960794679999999790e-01 38 | -1.312791140000000023e-01 -2.486493680000000095e-01 39 | -1.250511170000000172e-01 -3.447779850000000090e-01 40 | -1.289030150000000097e-01 -3.356717830000000014e-01 41 | -2.288265690000000074e-01 -8.499338500000000463e-02 42 | -5.442581180000000129e-01 3.154526060000000243e-01 43 | -7.036560060000000005e-01 3.846497499999999570e-01 44 | -7.049967040000000296e-01 3.497450260000000144e-01 45 | -7.051521000000000594e-01 3.324765009999999799e-01 46 | -6.941493530000000245e-01 3.306416929999999588e-01 47 | -4.815120539999999671e-01 1.498098910000000006e-01 48 | -2.028645480000000056e-01 -2.111323549999999938e-01 49 | -1.297861790000000015e-01 -3.099115300000000461e-01 50 | -1.234579320000000063e-01 -3.062985229999999892e-01 51 | -2.084859309999999855e-01 -2.747284549999999825e-01 52 | -1.877753299999999903e-01 -3.280964660000000310e-01 53 | -5.856711430000000052e-01 8.655563000000001533e-03 54 | -7.315770260000000746e-01 2.412328799999999829e-01 55 | -7.079476929999999335e-01 3.768447269999999905e-01 56 | -7.189877930000000417e-01 3.590033569999999674e-01 57 | -6.923284909999999348e-01 3.381936039999999810e-01 58 | -5.095875850000000096e-01 1.533861539999999968e-01 59 | -2.276015630000000067e-01 -1.949298100000000089e-01 60 | -1.112294459999999957e-01 -3.246945190000000148e-01 61 | -1.065125890000000047e-01 -3.241390380000000460e-01 62 | -2.372601170000000204e-01 -1.004810790000000009e-01 63 | -5.377744140000000339e-01 2.788573000000000301e-01 64 | -6.800805659999999975e-01 3.790632320000000277e-01 65 | -7.090087280000000325e-01 3.658084110000000000e-01 66 | -7.096049799999999408e-01 3.556458129999999773e-01 67 | -6.953916020000000531e-01 3.518840329999999850e-01 68 | -5.826724239999999666e-01 2.440412599999999821e-01 69 | -3.393087459999999944e-01 -4.081309499999999368e-02 70 | -1.910789489999999979e-01 -2.875541990000000103e-01 71 | -1.623500979999999982e-01 -3.347286379999999673e-01 72 | -1.567822419999999883e-01 -2.069817959999999957e-01 73 | -1.603040770000000170e-01 3.431170649999999989e-01 74 | -1.808427430000000002e-01 7.637008670000000610e-01 75 | -1.947307129999999997e-01 8.727271730000000227e-01 76 | -1.987186130000000162e-01 8.781805419999999529e-01 77 | -2.053231350000000177e-01 8.728751220000000588e-01 78 | -2.334693449999999948e-01 8.505306399999998934e-01 79 | -2.544196169999999868e-01 6.512421880000001106e-01 80 | -2.371720429999999991e-01 2.681205140000000320e-01 81 | -1.995537410000000067e-01 -1.069434360000000028e-01 82 | -1.781985319999999928e-01 -2.991551210000000238e-01 83 | -1.624500269999999968e-01 -3.215934449999999778e-01 84 | -1.561202999999999896e-01 -3.212408139999999857e-01 85 | -3.640779419999999877e-01 2.863220000000000088e-03 86 | -5.724375609999999837e-01 2.458258510000000119e-01 87 | -6.940995480000000661e-01 3.470617679999999927e-01 88 | -7.257116089999999797e-01 3.577388309999999794e-01 89 | -7.309974369999999722e-01 3.374722900000000081e-01 90 | -7.387392579999999542e-01 3.113011780000000117e-01 91 | -6.900628659999999970e-01 3.125410770000000005e-01 92 | -4.578406979999999904e-01 7.528645299999998930e-02 93 | -4.207922970000000373e-01 -1.739768520000000152e-01 94 | -3.387411499999999909e-01 -2.795646360000000330e-01 95 | -2.678801270000000234e-01 -3.249730220000000003e-01 96 | -2.140945739999999820e-01 -3.438616329999999999e-01 97 | -5.102629389999999709e-01 3.861421809999999732e-01 98 | -3.713910220000000151e-01 7.887363279999999310e-01 99 | -2.229380039999999952e-01 8.384943849999999532e-01 100 | -2.319291689999999906e-01 6.588040160000000478e-01 101 | -2.376166690000000026e-01 2.813414000000000192e-01 102 | -1.969737240000000167e-01 -1.240927889999999950e-01 103 | -1.575734410000000085e-01 -3.072149659999999782e-01 104 | -1.385904390000000097e-01 -3.192860109999999807e-01 105 | -2.563508609999999854e-01 -5.671629300000000096e-02 106 | -5.230040890000000608e-01 3.038916320000000226e-01 107 | -6.989789429999999637e-01 3.607649840000000108e-01 108 | -6.953792720000000482e-01 3.671864930000000027e-01 109 | -4.435480350000000072e-01 2.078107299999999991e-01 110 | -2.694966429999999802e-01 -1.142851720000000043e-01 111 | -2.592518919999999838e-01 -2.534420320000000393e-01 112 | -2.417241820000000097e-01 -6.162660999999999833e-02 113 | -2.421818539999999742e-01 3.602969059999999724e-01 114 | -1.844174040000000070e-01 8.490740970000000276e-01 115 | -1.933766329999999922e-01 8.603925169999999678e-01 116 | -2.166420290000000137e-01 8.252851560000000752e-01 117 | -3.261258850000000042e-01 4.890660710000000466e-01 118 | -2.646184690000000228e-01 1.545326080000000157e-01 119 | -2.409151610000000165e-01 -1.915746310000000230e-01 120 | -1.702423860000000233e-01 -2.526224209999999859e-01 121 | -1.553882450000000082e-01 8.976532000000000608e-03 122 | -1.498049929999999974e-01 3.120019229999999588e-01 123 | -1.395406800000000003e-01 3.383393550000000083e-01 124 | -1.533807530000000086e-01 3.431417850000000325e-01 125 | -1.758189240000000153e-01 2.377274020000000043e-01 126 | -1.783801569999999836e-01 -1.094205780000000044e-01 127 | -1.647490080000000023e-01 -3.136286620000000025e-01 128 | -1.609131319999999865e-01 -3.269676509999999703e-01 129 | -1.464676669999999958e-01 -1.252322770000000030e-01 130 | -1.412540280000000037e-01 2.066750029999999960e-01 131 | -1.229134219999999944e-01 3.552664179999999727e-01 132 | -1.224669270000000032e-01 3.610618590000000405e-01 133 | -1.421133579999999952e-01 3.405128480000000346e-01 134 | -1.732321780000000144e-01 5.529441799999999796e-02 135 | -1.577110439999999947e-01 -2.785817260000000295e-01 136 | -1.649250790000000022e-01 -3.604567260000000051e-01 137 | -1.616257019999999822e-01 -3.559135130000000147e-01 138 | -1.872780759999999878e-01 -1.821026919999999827e-01 139 | -4.070574339999999958e-01 1.078984300000000035e-01 140 | -6.070833740000000089e-01 3.122826229999999814e-01 141 | -7.054410400000000747e-01 3.738244319999999843e-01 142 | -7.211912839999999880e-01 3.580476989999999970e-01 143 | -7.250971680000000141e-01 3.554298099999999572e-01 144 | -6.822138670000000849e-01 3.487391659999999893e-01 145 | -5.085052190000000083e-01 1.617646329999999910e-01 146 | -3.971246340000000319e-01 -4.427178200000000258e-02 147 | -2.603146669999999996e-01 -2.433499600000000040e-01 148 | -1.543594209999999967e-01 -3.011791079999999732e-01 149 | -3.064190980000000009e-01 -9.989572099999999288e-02 150 | -5.278319089999999880e-01 1.978426359999999884e-01 151 | -6.739237060000000668e-01 3.226058959999999476e-01 152 | -7.287313229999999864e-01 3.377016909999999705e-01 153 | -7.166838380000000175e-01 3.283053279999999519e-01 154 | -7.172523190000000826e-01 3.073803710000000411e-01 155 | -5.875163569999999336e-01 2.104877930000000064e-01 156 | -3.808393549999999905e-01 -3.493328899999999931e-02 157 | -1.932634889999999828e-01 -2.658489989999999747e-01 158 | -1.266096040000000145e-01 -3.426492919999999942e-01 159 | -1.311705930000000020e-01 -3.085904540000000140e-01 160 | -1.351910100000000003e-01 -2.826922000000000046e-01 161 | -1.263805769999999939e-01 -1.882556200000000055e-02 162 | -1.292943270000000144e-01 2.545499270000000092e-01 163 | -1.354919430000000036e-01 3.403613280000000185e-01 164 | -1.479606019999999966e-01 2.794776919999999998e-01 165 | -1.777948759999999906e-01 4.720788600000000446e-02 166 | -1.739763490000000024e-01 -1.271154939999999955e-01 167 | -1.649057770000000034e-01 -2.407736970000000087e-01 168 | -1.528841710000000131e-01 -3.052147829999999895e-01 169 | -2.354851229999999906e-01 -1.684638519999999973e-01 170 | -2.874670100000000228e-01 1.218985439999999976e-01 171 | -3.864667049999999660e-01 4.607424009999999681e-01 172 | -3.418704220000000071e-01 7.290773319999999114e-01 173 | -1.565851289999999896e-01 8.662064210000000042e-01 174 | -1.946052860000000162e-01 8.256256100000000098e-01 175 | -2.330844420000000028e-01 5.838748169999999904e-01 176 | -2.194864810000000110e-01 1.944766239999999868e-01 177 | -1.615282589999999796e-01 -2.465103609999999834e-01 178 | -1.428809659999999981e-01 -3.363093260000000195e-01 179 | -1.484655459999999760e-01 -2.715078129999999867e-01 180 | -1.608519740000000087e-01 5.283107799999999660e-02 181 | -1.770326230000000001e-01 4.602849729999999862e-01 182 | -1.763532869999999975e-01 7.058421630000000224e-01 183 | -1.761489410000000033e-01 8.472566530000000817e-01 184 | -1.850833129999999993e-01 8.689289550000000029e-01 185 | -2.162384950000000028e-01 8.419180910000000351e-01 186 | -2.211345980000000155e-01 5.816871340000000501e-01 187 | -4.637424930000000334e-01 2.213310850000000107e-01 188 | -2.756309509999999574e-01 -2.710369899999999846e-02 189 | -2.139981380000000044e-01 -2.537791440000000120e-01 190 | -1.707786560000000009e-01 -2.956747439999999894e-01 191 | -1.685817569999999987e-01 2.387214699999999981e-02 192 | -1.496840520000000119e-01 3.166101070000000295e-01 193 | -1.260871580000000047e-01 3.474600829999999752e-01 194 | -1.414895940000000241e-01 3.186377560000000497e-01 195 | -1.488226619999999945e-01 -2.229438800000000179e-02 196 | -1.598507080000000080e-01 -3.069746700000000050e-01 197 | -1.609823149999999869e-01 -3.492677610000000099e-01 198 | -1.850569150000000163e-01 -2.710282589999999936e-01 199 | -1.575782930000000082e-01 -3.314696659999999961e-01 200 | -4.207583619999999969e-01 -5.303351599999999583e-02 201 | -6.551191410000000159e-01 1.566475680000000148e-01 202 | -7.099584959999999390e-01 2.854205930000000002e-01 203 | -7.358398440000000207e-01 2.787123109999999904e-01 204 | -7.147268679999999597e-01 2.865740969999999721e-01 205 | -5.460598750000000834e-01 1.445924070000000061e-01 206 | -2.742046510000000215e-01 -1.449969020000000108e-01 207 | -1.353131870000000014e-01 -3.215563049999999867e-01 208 | -1.117601319999999981e-01 -3.484841309999999748e-01 209 | -1.115015559999999878e-01 -3.524176640000000194e-01 210 | -------------------------------------------------------------------------------- /GPSegmentation.py: -------------------------------------------------------------------------------- 1 | # encoding: utf8 2 | from __future__ import unicode_literals 3 | from __future__ import print_function 4 | import GaussianProcessMultiDim 5 | import random 6 | import math 7 | import matplotlib.pyplot as plt 8 | import time 9 | import numpy as np 10 | import sys 11 | import os 12 | #from scipy.special import logsumexp 13 | import pyximport 14 | pyximport.install(setup_args={'include_dirs':[np.get_include()]}, inplace=True) 15 | from cymath import logsumexp, calc_forward_probability 16 | 17 | 18 | class GPSegmentation(): 19 | # parameters 20 | MAX_LEN = 20 21 | MIN_LEN = 5 22 | AVE_LEN = 10 23 | SKIP_LEN = 1 24 | 25 | def __init__(self, dim, nclass): 26 | self.dim = dim 27 | self.numclass = nclass 28 | self.segmlen = 3 29 | self.gps = [ GaussianProcessMultiDim.GPMD(dim) for i in range(self.numclass) ] 30 | self.segm_in_class= [ [] for i in range(self.numclass) ] 31 | self.segmclass = {} 32 | self.segments = [] 33 | self.trans_prob = np.ones( (nclass,nclass) ) 34 | self.trans_prob_bos = np.ones( nclass ) 35 | self.trans_prob_eos = np.ones( nclass ) 36 | self.is_initialized = False 37 | 38 | self.prior_table = [ i*math.log(self.AVE_LEN) -self.AVE_LEN - sum(np.log(np.arange(1,i+1))) for i in range(1,self.MAX_LEN+1) ] 39 | 40 | def load_data(self, filenames, classfile=None ): 41 | self.data = [] 42 | self.segments = [] 43 | self.is_initialized = False 44 | 45 | for n, fname in enumerate(filenames): 46 | y = np.loadtxt( fname ) 47 | segm = [] 48 | self.data.append( y ) 49 | 50 | # ランダムに切る 51 | i = 0 52 | while i=len(y): 56 | length = len(y)-i 57 | 58 | segm.append( y[i:i+length+1] ) 59 | 60 | i+=length 61 | 62 | self.segments.append( segm ) 63 | 64 | # ランダムに割り振る 65 | for i,s in enumerate(segm): 66 | c = random.randint(0,self.numclass-1) 67 | self.segmclass[(n,i)] = c 68 | 69 | # 遷移確率更新 70 | self.calc_trans_prob() 71 | 72 | 73 | 74 | 75 | def load_model( self, basename ): 76 | # GP読み込み 77 | for c in range(self.numclass): 78 | filename = basename + "class%03d.npy" % c 79 | self.segm_in_class[c] = np.load( filename, allow_pickle=True) 80 | self.update_gp( c ) 81 | 82 | # 遷移確率更新 83 | self.trans_prob = np.load( basename+"trans.npy", allow_pickle=True ) 84 | self.trans_prob_bos = np.load( basename+"trans_bos.npy", allow_pickle=True ) 85 | self.trans_prob_eos = np.load( basename+"trans_eos.npy", allow_pickle=True ) 86 | 87 | 88 | def update_gp(self, c ): 89 | datay = [] 90 | datax = [] 91 | for s in self.segm_in_class[c]: 92 | datay += [ y for y in s ] 93 | datax += range(len(s)) 94 | 95 | self.gps[c].learn( datax, datay ) 96 | 97 | 98 | def calc_emission_logprob( self, c, segm ): 99 | gp = self.gps[c] 100 | slen = len(segm) 101 | 102 | if len(segm) > 2: 103 | #plen = self.AVE_LEN**slen * math.exp(-self.AVE_LEN) / math.factorial(slen) 104 | log_plen = (slen*math.log(self.AVE_LEN) + (-self.AVE_LEN)*math.log(math.e)) - (sum(np.log(np.arange(1,slen+1)))) 105 | p = gp.calc_lik( np.arange(len(segm), dtype=float) , segm ) 106 | #return p + math.log(plen) 107 | return p + log_plen 108 | else: 109 | return math.log(1.0e-100) 110 | 111 | def calc_emission_logprob_all(self, d): 112 | T = len(d) 113 | # 出力確率を計算 114 | emission_prob_all = np.zeros( ( self.numclass, self.MAX_LEN, len(d)) ) 115 | for c in range(self.numclass): 116 | params = self.gps[c].predict( range(self.MAX_LEN) ) 117 | for k in range(self.MAX_LEN): 118 | for dim in range( self.dim ): 119 | mu = params[dim][0][k] 120 | sig = params[dim][1][k] 121 | emission_prob_all[c, k, 0:T-k] += -math.log(math.sqrt( 2*math.pi*sig**2)) - (d[k:,dim]-mu)**2 / (2*sig**2) 122 | 123 | # 累積確率にする 124 | for k in range(1, self.MAX_LEN): 125 | emission_prob_all[:, k, :] += emission_prob_all[:, k-1, :] 126 | 127 | for k in range(self.MAX_LEN): 128 | emission_prob_all[:,k,:] += self.prior_table[k] 129 | 130 | return emission_prob_all 131 | 132 | 133 | def save_model(self, basename ): 134 | if not os.path.exists(basename): 135 | os.mkdir( basename ) 136 | 137 | for n,segm in enumerate(self.segments): 138 | classes = [] 139 | cut_points = [] 140 | for i, s in enumerate(segm): 141 | c = self.segmclass[(n,i)] 142 | classes += [ c for j in range(len(s)) ] 143 | cut_points += [0] * len(s) 144 | cut_points[-1] = 1 145 | np.savetxt( basename+"segm%03d.txt" % n, np.vstack([classes,cut_points]).T, fmt=str("%d") ) 146 | 147 | 148 | # 各クラスに分類されたデータを保存 149 | for c in range(len(self.gps)): 150 | for d in range(self.dim): 151 | plt.clf() 152 | for data in self.segm_in_class[c]: 153 | if self.dim==1: 154 | plt.plot( range(len(data)), data, "o-" ) 155 | else: 156 | plt.plot( range(len(data[:,d])), data[:,d], "o-" ) 157 | plt.ylim( -1, 1 ) 158 | plt.savefig( basename+"class%03d_dim%03d.png" % (c, d) ) 159 | 160 | # テキストでも保存 161 | np.save( basename + "trans.npy" , self.trans_prob ) 162 | np.save( basename + "trans_bos.npy" , self.trans_prob_bos ) 163 | np.save( basename + "trans_eos.npy" , self.trans_prob_eos ) 164 | 165 | for c in range(self.numclass): 166 | np.save( basename+"class%03d.npy" % c, np.array(self.segm_in_class[c], dtype=object) ) 167 | 168 | def calc_vitervi_path(self, d ): 169 | T = len(d) 170 | log_a = np.zeros( (len(d), self.MAX_LEN, self.numclass) ) - 99999999999999 171 | valid = np.zeros( (len(d), self.MAX_LEN, self.numclass) ) # 計算された有効な値可どうか.計算されていない場所の確率を0にするため. 172 | z = np.ones( T ) # 正規化定数 173 | path_kc = -np.ones( (len(d), self.MAX_LEN, self.numclass, 2), dtype=np.int32 ) 174 | emission_prob_all = self.calc_emission_logprob_all( d ) 175 | 176 | 177 | # 前向き確率計算 178 | for t in range(T): 179 | for k in range(self.MIN_LEN,self.MAX_LEN,self.SKIP_LEN): 180 | if t-k<0: 181 | break 182 | 183 | segm = d[t-k:t+1] 184 | for c in range(self.numclass): 185 | #out_prob = self.calc_emission_logprob( c, segm ) 186 | out_prob = emission_prob_all[c,k,t-k] 187 | foward_prob = 0.0 188 | 189 | # 遷移確率 190 | tt = t-k-1 191 | if tt>=0: 192 | prev_prob = log_a[tt,:,:] + z[tt] + np.log(self.trans_prob[:,c]) 193 | 194 | # 最大値を取る 195 | idx = np.argmax( prev_prob.reshape( self.MAX_LEN*self.numclass )) 196 | kk = int(idx/self.numclass) 197 | cc = idx % self.numclass 198 | 199 | path_kc[t, k, c, 0] = kk 200 | path_kc[t, k, c, 1] = cc 201 | 202 | foward_prob = prev_prob[kk, cc] + out_prob 203 | else: 204 | # 最初の単語 205 | foward_prob = out_prob + math.log(self.trans_prob_bos[c]) 206 | 207 | path_kc[t, k, c, 0] = t+1 208 | path_kc[t, k, c, 1] = -1 209 | 210 | 211 | if t==T-1: 212 | # 最後の単語 213 | foward_prob += math.log(self.trans_prob_eos[c]) 214 | 215 | 216 | log_a[t,k,c] = foward_prob 217 | valid[t,k,c] = 1.0 218 | if math.isnan(foward_prob): 219 | print( "a[t=%d,k=%d,c=%d] became NAN!!" % (t,k,c) ) 220 | sys.exit(-1) 221 | # 正規化 222 | if t-self.MIN_LEN>=0: 223 | z[t] = logsumexp( log_a[t,:,:] ) 224 | log_a[t,:,:] -= z[t] 225 | #z[t] = logsumexp( a[t,:,:] ) 226 | #a[t,:,:] -= z[t] 227 | 228 | # バックトラック 229 | t = T-1 230 | idx = np.argmax( log_a[t].reshape( self.MAX_LEN*self.numclass )) 231 | k = int(idx/self.numclass) 232 | c = idx % self.numclass 233 | 234 | segm = [ d[t-k:t+1] ] 235 | segm_class = [ c ] 236 | 237 | while True: 238 | kk, cc = path_kc[t, k, c] 239 | 240 | t = t-k-1 241 | k = kk 242 | c = cc 243 | 244 | if t<=0: 245 | break 246 | 247 | if t-k-1<=0: 248 | #先頭 249 | s = d[0:t+1] 250 | else: 251 | #先頭以外 252 | s = d[t-k:t+1] 253 | 254 | segm.insert( 0, s ) 255 | segm_class.insert( 0, c ) 256 | 257 | return segm, segm_class 258 | 259 | 260 | 261 | def forward_filtering(self, d ): 262 | #### cythonで処理 ####### 263 | # 全時刻の出力確率をあらかじめ計算 264 | emission_prob_all = self.calc_emission_logprob_all( d ) 265 | forward_prob = calc_forward_probability( emission_prob_all, self.trans_prob, self.trans_prob_bos, self.trans_prob_eos, len(d), self.MIN_LEN, self.SKIP_LEN, self.MAX_LEN, self.numclass ) 266 | return forward_prob 267 | 268 | """ 269 | ### Pythonで計算 ######## 270 | T = len(d) 271 | log_a = np.log( np.zeros( (len(d), self.MAX_LEN, self.numclass) ) + 1.0e-100 ) # 前向き確率.対数で確率を保持.1.0e-100で確率0を近似的に表現. 272 | #a = np.zeros( (len(d), self.MAX_LEN, self.numclass) ) + 1.0-e100 273 | valid = np.zeros( (len(d), self.MAX_LEN, self.numclass) ) # 計算された有効な値可どうか.計算されていない場所の確率を0にするため. 274 | z = np.ones( T ) # 正規化定数 275 | m = np.zeros( len(d) ) # t-kの計算結果を入れるバッファ 276 | 277 | # 全時刻の出力確率をあらかじめ計算 278 | emission_prob_all = self.calc_emission_logprob_all( d ) 279 | 280 | for t in range(T): 281 | for k in range(self.MIN_LEN,self.MAX_LEN,self.SKIP_LEN): 282 | if t-k<0: 283 | break 284 | 285 | #segm = d[t-k:t+1] 286 | for c in range(self.numclass): 287 | #out_prob = self.calc_emission_logprob( c, segm ) 288 | out_prob = emission_prob_all[c,k-1,t-k] 289 | foward_prob = 0.0 290 | 291 | # 遷移確率 292 | tt = t-k-1 293 | if tt>=0: 294 | #for kk in range(self.MAX_LEN): 295 | # for cc in range(self.numclass): 296 | # foward_prob += a[tt,kk,cc] * self.trans_prob[cc, c] 297 | #foward_prob = math.log(np.sum( a[tt,:,:] * self.trans_prob[:,c] )) + out_prob 298 | 299 | 300 | if m[tt]==0: 301 | #m[tt] = torch.logsumexp( torch.Tensor(log_a[tt,:,:] + z[tt] + np.log(self.trans_prob[:,c])).flatten(), -1 ) 302 | m[tt] = logsumexp( log_a[tt,:,:] + z[tt] + np.log(self.trans_prob[:,c]) ) 303 | foward_prob = m[tt] + out_prob 304 | #foward_prob = logsumexp( log_a[tt,:,:] + z[tt] + np.log(self.trans_prob[:,c]) ) + out_prob 305 | 306 | 307 | else: 308 | # 最初の単語 309 | foward_prob = out_prob + math.log(self.trans_prob_bos[c]) 310 | 311 | if t==T-1: 312 | # 最後の単語 313 | foward_prob += math.log(self.trans_prob_eos[c]) 314 | 315 | # 正規化を元に戻す 316 | log_a[t,k,c] = foward_prob 317 | #a[t,k,c] = foward_prob 318 | valid[t,k,c] = 1.0 319 | if math.isnan(foward_prob): 320 | print( "a[t=%d,k=%d,c=%d] became NAN!!" % (t,k,c) ) 321 | sys.exit(-1) 322 | # 正規化 323 | if t-self.MIN_LEN>=0: 324 | z[t] = logsumexp( log_a[t,:,:] ) 325 | log_a[t,:,:] -= z[t] 326 | #z[t] = logsumexp( a[t,:,:] ) 327 | #a[t,:,:] -= z[t] 328 | return np.exp(log_a)*valid 329 | """ 330 | 331 | 332 | def sample_idx(self, prob ): 333 | accm_prob = [0,] * len(prob) 334 | for i in range(len(prob)): 335 | accm_prob[i] = prob[i] + accm_prob[i-1] 336 | 337 | rnd = random.random() * accm_prob[-1] 338 | for i in range(len(prob)): 339 | if rnd <= accm_prob[i]: 340 | return i 341 | 342 | 343 | def backward_sampling(self, a, d): 344 | T = a.shape[0] 345 | t = T-1 346 | 347 | segm = [] 348 | segm_class = [] 349 | 350 | c = -1 351 | while True: 352 | if t==T-1: 353 | transp = self.trans_prob_eos 354 | else: 355 | transp = self.trans_prob[:,c] 356 | 357 | idx = self.sample_idx( (a[t]*transp).reshape( self.MAX_LEN*self.numclass )) 358 | 359 | k = int(idx/self.numclass) 360 | c = idx % self.numclass 361 | 362 | if t-k-1<=0: 363 | #先頭 364 | s = d[0:t+1] 365 | else: 366 | #先頭以外 367 | s = d[t-k:t+1] 368 | 369 | segm.insert( 0, s ) 370 | segm_class.insert( 0, c ) 371 | 372 | t = t-k-1 373 | 374 | if t<=0: 375 | break 376 | 377 | return segm, segm_class 378 | 379 | 380 | def calc_trans_prob( self ): 381 | self.trans_prob = np.zeros( (self.numclass,self.numclass) ) 382 | self.trans_prob_bos = np.zeros( self.numclass ) 383 | self.trans_prob_eos = np.zeros( self.numclass ) 384 | self.trans_prob += 0.1 385 | self.trans_prob_bos += 0.1 386 | self.trans_prob_eos += 0.1 387 | # 数え上げ 388 | for n,segm in enumerate(self.segments): 389 | if (n,0) in self.segmclass: 390 | c_begin = self.segmclass[(n, 0)] 391 | self.trans_prob_bos[c_begin]+=1 392 | if (n, len(segm)-1) in self.segmclass: 393 | c_end = self.segmclass[(n, len(segm)-1)] 394 | self.trans_prob_eos[c_end]+=1 395 | for i in range(1,len(segm)): 396 | try: 397 | cc = self.segmclass[ (n, i-1) ] 398 | c = self.segmclass[ (n, i) ] 399 | except KeyError: 400 | # gibss samplingで除かれているものは無視 401 | continue 402 | self.trans_prob[cc,c] += 1 403 | # 正規化 404 | self.trans_prob = self.trans_prob / self.trans_prob.sum(1).reshape(self.numclass,1) 405 | self.trans_prob_bos = self.trans_prob_bos / np.sum( self.trans_prob_bos ) 406 | self.trans_prob_eos = self.trans_prob_eos / np.sum( self.trans_prob_eos ) 407 | 408 | 409 | # list.remove( elem )だとValueErrorになる 410 | def remove_ndarray(self, lst, elem ): 411 | l = len(elem) 412 | for i,e in enumerate(lst): 413 | if len(e)!=l: 414 | continue 415 | if (e==elem).all(): 416 | lst.pop(i) 417 | return 418 | raise ValueError( "ndarray is not found!!" ) 419 | 420 | def learn(self): 421 | if self.is_initialized==False: 422 | # GPの学習 423 | for n in range(len(self.segments)): 424 | for i, s in enumerate(self.segments[n]): 425 | c = self.segmclass[(n,i)] 426 | self.segm_in_class[c].append( s ) 427 | 428 | # 各クラス毎に学習 429 | for c in range(self.numclass): 430 | self.update_gp( c ) 431 | 432 | self.is_initialized = True 433 | 434 | self.update(True) 435 | 436 | def recog(self): 437 | #self.update(False) 438 | self.segmclass.clear() 439 | 440 | for n, d in enumerate(self.data): 441 | # viterviで解く 442 | segms, classes = self.calc_vitervi_path( d ) 443 | self.segments[n] = segms 444 | for i, (s, c) in enumerate(zip( segms, classes )): 445 | self.segmclass[(n,i)] = c 446 | 447 | def update(self, learning_phase=True ): 448 | 449 | for n in range(len(self.segments)): 450 | d = self.data[n] 451 | segm = self.segments[n] 452 | 453 | for i, s in enumerate(segm): 454 | c = self.segmclass[(n,i)] 455 | self.segmclass.pop( (n,i) ) 456 | 457 | if learning_phase: 458 | # パラメータ更新 459 | self.remove_ndarray( self.segm_in_class[c], s ) 460 | 461 | if learning_phase: 462 | # GP更新 463 | for c in range(self.numclass): 464 | self.update_gp( c ) 465 | 466 | # 遷移確率更新 467 | self.calc_trans_prob() 468 | 469 | start = time.time() 470 | print( "forward...", end="") 471 | a = self.forward_filtering( d ) 472 | 473 | print( "backward...", end="" ) 474 | segm, segm_class = self.backward_sampling( a, d ) 475 | print( time.time()-start, "sec" ) 476 | 477 | print( "Number of classified segments: [", end="") 478 | for s in self.segm_in_class: 479 | print( len(s), end=" " ) 480 | print( "]" ) 481 | 482 | 483 | self.segments[n] = segm 484 | 485 | start = time.time() 486 | for i, (s,c) in enumerate(zip( segm, segm_class )): 487 | self.segmclass[(n,i)] = c 488 | 489 | # パラメータ更新 490 | if learning_phase: 491 | self.segm_in_class[c].append(s) 492 | 493 | if learning_phase: 494 | # GP更新 495 | for c in range(self.numclass): 496 | self.update_gp( c ) 497 | 498 | # 遷移確率更新 499 | self.calc_trans_prob() 500 | print( "parameter update...", time.time()-start, "sec" ) 501 | 502 | # hyperparameter更新 503 | #for c in range(self.numclass): 504 | # self.gps[c].estimate_hyperparams(100) 505 | 506 | return 507 | 508 | def calc_lik(self): 509 | lik = 0 510 | for n, segm in enumerate(self.segments): 511 | for i, s in enumerate(segm): 512 | c = self.segmclass[(n,i)] 513 | #lik += self.gps[c].calc_lik( np.arange(len(s),dtype=np.float) , np.array(s) ) 514 | lik += self.gps[c].calc_lik( np.arange(len(s), dtype=float) , s ) 515 | 516 | return lik 517 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Attribution-NonCommercial 4.0 International 2 | 3 | ======================================================================= 4 | 5 | Creative Commons Corporation ("Creative Commons") is not a law firm and 6 | does not provide legal services or legal advice. Distribution of 7 | Creative Commons public licenses does not create a lawyer-client or 8 | other relationship. Creative Commons makes its licenses and related 9 | information available on an "as-is" basis. Creative Commons gives no 10 | warranties regarding its licenses, any material licensed under their 11 | terms and conditions, or any related information. Creative Commons 12 | disclaims all liability for damages resulting from their use to the 13 | fullest extent possible. 14 | 15 | Using Creative Commons Public Licenses 16 | 17 | Creative Commons public licenses provide a standard set of terms and 18 | conditions that creators and other rights holders may use to share 19 | original works of authorship and other material subject to copyright 20 | and certain other rights specified in the public license below. The 21 | following considerations are for informational purposes only, are not 22 | exhaustive, and do not form part of our licenses. 23 | 24 | Considerations for licensors: Our public licenses are 25 | intended for use by those authorized to give the public 26 | permission to use material in ways otherwise restricted by 27 | copyright and certain other rights. Our licenses are 28 | irrevocable. Licensors should read and understand the terms 29 | and conditions of the license they choose before applying it. 30 | Licensors should also secure all rights necessary before 31 | applying our licenses so that the public can reuse the 32 | material as expected. Licensors should clearly mark any 33 | material not subject to the license. This includes other CC- 34 | licensed material, or material used under an exception or 35 | limitation to copyright. More considerations for licensors: 36 | wiki.creativecommons.org/Considerations_for_licensors 37 | 38 | Considerations for the public: By using one of our public 39 | licenses, a licensor grants the public permission to use the 40 | licensed material under specified terms and conditions. If 41 | the licensor's permission is not necessary for any reason--for 42 | example, because of any applicable exception or limitation to 43 | copyright--then that use is not regulated by the license. Our 44 | licenses grant only permissions under copyright and certain 45 | other rights that a licensor has authority to grant. Use of 46 | the licensed material may still be restricted for other 47 | reasons, including because others have copyright or other 48 | rights in the material. A licensor may make special requests, 49 | such as asking that all changes be marked or described. 50 | Although not required by our licenses, you are encouraged to 51 | respect those requests where reasonable. More considerations 52 | for the public: 53 | wiki.creativecommons.org/Considerations_for_licensees 54 | 55 | ======================================================================= 56 | 57 | Creative Commons Attribution-NonCommercial 4.0 International Public 58 | License 59 | 60 | By exercising the Licensed Rights (defined below), You accept and agree 61 | to be bound by the terms and conditions of this Creative Commons 62 | Attribution-NonCommercial 4.0 International Public License ("Public 63 | License"). To the extent this Public License may be interpreted as a 64 | contract, You are granted the Licensed Rights in consideration of Your 65 | acceptance of these terms and conditions, and the Licensor grants You 66 | such rights in consideration of benefits the Licensor receives from 67 | making the Licensed Material available under these terms and 68 | conditions. 69 | 70 | 71 | Section 1 -- Definitions. 72 | 73 | a. Adapted Material means material subject to Copyright and Similar 74 | Rights that is derived from or based upon the Licensed Material 75 | and in which the Licensed Material is translated, altered, 76 | arranged, transformed, or otherwise modified in a manner requiring 77 | permission under the Copyright and Similar Rights held by the 78 | Licensor. For purposes of this Public License, where the Licensed 79 | Material is a musical work, performance, or sound recording, 80 | Adapted Material is always produced where the Licensed Material is 81 | synched in timed relation with a moving image. 82 | 83 | b. Adapter's License means the license You apply to Your Copyright 84 | and Similar Rights in Your contributions to Adapted Material in 85 | accordance with the terms and conditions of this Public License. 86 | 87 | c. Copyright and Similar Rights means copyright and/or similar rights 88 | closely related to copyright including, without limitation, 89 | performance, broadcast, sound recording, and Sui Generis Database 90 | Rights, without regard to how the rights are labeled or 91 | categorized. For purposes of this Public License, the rights 92 | specified in Section 2(b)(1)-(2) are not Copyright and Similar 93 | Rights. 94 | d. Effective Technological Measures means those measures that, in the 95 | absence of proper authority, may not be circumvented under laws 96 | fulfilling obligations under Article 11 of the WIPO Copyright 97 | Treaty adopted on December 20, 1996, and/or similar international 98 | agreements. 99 | 100 | e. Exceptions and Limitations means fair use, fair dealing, and/or 101 | any other exception or limitation to Copyright and Similar Rights 102 | that applies to Your use of the Licensed Material. 103 | 104 | f. Licensed Material means the artistic or literary work, database, 105 | or other material to which the Licensor applied this Public 106 | License. 107 | 108 | g. Licensed Rights means the rights granted to You subject to the 109 | terms and conditions of this Public License, which are limited to 110 | all Copyright and Similar Rights that apply to Your use of the 111 | Licensed Material and that the Licensor has authority to license. 112 | 113 | h. Licensor means the individual(s) or entity(ies) granting rights 114 | under this Public License. 115 | 116 | i. NonCommercial means not primarily intended for or directed towards 117 | commercial advantage or monetary compensation. For purposes of 118 | this Public License, the exchange of the Licensed Material for 119 | other material subject to Copyright and Similar Rights by digital 120 | file-sharing or similar means is NonCommercial provided there is 121 | no payment of monetary compensation in connection with the 122 | exchange. 123 | 124 | j. Share means to provide material to the public by any means or 125 | process that requires permission under the Licensed Rights, such 126 | as reproduction, public display, public performance, distribution, 127 | dissemination, communication, or importation, and to make material 128 | available to the public including in ways that members of the 129 | public may access the material from a place and at a time 130 | individually chosen by them. 131 | 132 | k. Sui Generis Database Rights means rights other than copyright 133 | resulting from Directive 96/9/EC of the European Parliament and of 134 | the Council of 11 March 1996 on the legal protection of databases, 135 | as amended and/or succeeded, as well as other essentially 136 | equivalent rights anywhere in the world. 137 | 138 | l. You means the individual or entity exercising the Licensed Rights 139 | under this Public License. Your has a corresponding meaning. 140 | 141 | 142 | Section 2 -- Scope. 143 | 144 | a. License grant. 145 | 146 | 1. Subject to the terms and conditions of this Public License, 147 | the Licensor hereby grants You a worldwide, royalty-free, 148 | non-sublicensable, non-exclusive, irrevocable license to 149 | exercise the Licensed Rights in the Licensed Material to: 150 | 151 | a. reproduce and Share the Licensed Material, in whole or 152 | in part, for NonCommercial purposes only; and 153 | 154 | b. produce, reproduce, and Share Adapted Material for 155 | NonCommercial purposes only. 156 | 157 | 2. Exceptions and Limitations. For the avoidance of doubt, where 158 | Exceptions and Limitations apply to Your use, this Public 159 | License does not apply, and You do not need to comply with 160 | its terms and conditions. 161 | 162 | 3. Term. The term of this Public License is specified in Section 163 | 6(a). 164 | 165 | 4. Media and formats; technical modifications allowed. The 166 | Licensor authorizes You to exercise the Licensed Rights in 167 | all media and formats whether now known or hereafter created, 168 | and to make technical modifications necessary to do so. The 169 | Licensor waives and/or agrees not to assert any right or 170 | authority to forbid You from making technical modifications 171 | necessary to exercise the Licensed Rights, including 172 | technical modifications necessary to circumvent Effective 173 | Technological Measures. For purposes of this Public License, 174 | simply making modifications authorized by this Section 2(a) 175 | (4) never produces Adapted Material. 176 | 177 | 5. Downstream recipients. 178 | 179 | a. Offer from the Licensor -- Licensed Material. Every 180 | recipient of the Licensed Material automatically 181 | receives an offer from the Licensor to exercise the 182 | Licensed Rights under the terms and conditions of this 183 | Public License. 184 | 185 | b. No downstream restrictions. You may not offer or impose 186 | any additional or different terms or conditions on, or 187 | apply any Effective Technological Measures to, the 188 | Licensed Material if doing so restricts exercise of the 189 | Licensed Rights by any recipient of the Licensed 190 | Material. 191 | 192 | 6. No endorsement. Nothing in this Public License constitutes or 193 | may be construed as permission to assert or imply that You 194 | are, or that Your use of the Licensed Material is, connected 195 | with, or sponsored, endorsed, or granted official status by, 196 | the Licensor or others designated to receive attribution as 197 | provided in Section 3(a)(1)(A)(i). 198 | 199 | b. Other rights. 200 | 201 | 1. Moral rights, such as the right of integrity, are not 202 | licensed under this Public License, nor are publicity, 203 | privacy, and/or other similar personality rights; however, to 204 | the extent possible, the Licensor waives and/or agrees not to 205 | assert any such rights held by the Licensor to the limited 206 | extent necessary to allow You to exercise the Licensed 207 | Rights, but not otherwise. 208 | 209 | 2. Patent and trademark rights are not licensed under this 210 | Public License. 211 | 212 | 3. To the extent possible, the Licensor waives any right to 213 | collect royalties from You for the exercise of the Licensed 214 | Rights, whether directly or through a collecting society 215 | under any voluntary or waivable statutory or compulsory 216 | licensing scheme. In all other cases the Licensor expressly 217 | reserves any right to collect such royalties, including when 218 | the Licensed Material is used other than for NonCommercial 219 | purposes. 220 | 221 | 222 | Section 3 -- License Conditions. 223 | 224 | Your exercise of the Licensed Rights is expressly made subject to the 225 | following conditions. 226 | 227 | a. Attribution. 228 | 229 | 1. If You Share the Licensed Material (including in modified 230 | form), You must: 231 | 232 | a. retain the following if it is supplied by the Licensor 233 | with the Licensed Material: 234 | 235 | i. identification of the creator(s) of the Licensed 236 | Material and any others designated to receive 237 | attribution, in any reasonable manner requested by 238 | the Licensor (including by pseudonym if 239 | designated); 240 | 241 | ii. a copyright notice; 242 | 243 | iii. a notice that refers to this Public License; 244 | 245 | iv. a notice that refers to the disclaimer of 246 | warranties; 247 | 248 | v. a URI or hyperlink to the Licensed Material to the 249 | extent reasonably practicable; 250 | 251 | b. indicate if You modified the Licensed Material and 252 | retain an indication of any previous modifications; and 253 | 254 | c. indicate the Licensed Material is licensed under this 255 | Public License, and include the text of, or the URI or 256 | hyperlink to, this Public License. 257 | 258 | 2. You may satisfy the conditions in Section 3(a)(1) in any 259 | reasonable manner based on the medium, means, and context in 260 | which You Share the Licensed Material. For example, it may be 261 | reasonable to satisfy the conditions by providing a URI or 262 | hyperlink to a resource that includes the required 263 | information. 264 | 265 | 3. If requested by the Licensor, You must remove any of the 266 | information required by Section 3(a)(1)(A) to the extent 267 | reasonably practicable. 268 | 269 | 4. If You Share Adapted Material You produce, the Adapter's 270 | License You apply must not prevent recipients of the Adapted 271 | Material from complying with this Public License. 272 | 273 | 274 | Section 4 -- Sui Generis Database Rights. 275 | 276 | Where the Licensed Rights include Sui Generis Database Rights that 277 | apply to Your use of the Licensed Material: 278 | 279 | a. for the avoidance of doubt, Section 2(a)(1) grants You the right 280 | to extract, reuse, reproduce, and Share all or a substantial 281 | portion of the contents of the database for NonCommercial purposes 282 | only; 283 | 284 | b. if You include all or a substantial portion of the database 285 | contents in a database in which You have Sui Generis Database 286 | Rights, then the database in which You have Sui Generis Database 287 | Rights (but not its individual contents) is Adapted Material; and 288 | 289 | c. You must comply with the conditions in Section 3(a) if You Share 290 | all or a substantial portion of the contents of the database. 291 | 292 | For the avoidance of doubt, this Section 4 supplements and does not 293 | replace Your obligations under this Public License where the Licensed 294 | Rights include other Copyright and Similar Rights. 295 | 296 | 297 | Section 5 -- Disclaimer of Warranties and Limitation of Liability. 298 | 299 | a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE 300 | EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS 301 | AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF 302 | ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, 303 | IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, 304 | WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR 305 | PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, 306 | ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT 307 | KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT 308 | ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. 309 | 310 | b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE 311 | TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, 312 | NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, 313 | INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, 314 | COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR 315 | USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN 316 | ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR 317 | DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR 318 | IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. 319 | 320 | c. The disclaimer of warranties and limitation of liability provided 321 | above shall be interpreted in a manner that, to the extent 322 | possible, most closely approximates an absolute disclaimer and 323 | waiver of all liability. 324 | 325 | 326 | Section 6 -- Term and Termination. 327 | 328 | a. This Public License applies for the term of the Copyright and 329 | Similar Rights licensed here. However, if You fail to comply with 330 | this Public License, then Your rights under this Public License 331 | terminate automatically. 332 | 333 | b. Where Your right to use the Licensed Material has terminated under 334 | Section 6(a), it reinstates: 335 | 336 | 1. automatically as of the date the violation is cured, provided 337 | it is cured within 30 days of Your discovery of the 338 | violation; or 339 | 340 | 2. upon express reinstatement by the Licensor. 341 | 342 | For the avoidance of doubt, this Section 6(b) does not affect any 343 | right the Licensor may have to seek remedies for Your violations 344 | of this Public License. 345 | 346 | c. For the avoidance of doubt, the Licensor may also offer the 347 | Licensed Material under separate terms or conditions or stop 348 | distributing the Licensed Material at any time; however, doing so 349 | will not terminate this Public License. 350 | 351 | d. Sections 1, 5, 6, 7, and 8 survive termination of this Public 352 | License. 353 | 354 | 355 | Section 7 -- Other Terms and Conditions. 356 | 357 | a. The Licensor shall not be bound by any additional or different 358 | terms or conditions communicated by You unless expressly agreed. 359 | 360 | b. Any arrangements, understandings, or agreements regarding the 361 | Licensed Material not stated herein are separate from and 362 | independent of the terms and conditions of this Public License. 363 | 364 | 365 | Section 8 -- Interpretation. 366 | 367 | a. For the avoidance of doubt, this Public License does not, and 368 | shall not be interpreted to, reduce, limit, restrict, or impose 369 | conditions on any use of the Licensed Material that could lawfully 370 | be made without permission under this Public License. 371 | 372 | b. To the extent possible, if any provision of this Public License is 373 | deemed unenforceable, it shall be automatically reformed to the 374 | minimum extent necessary to make it enforceable. If the provision 375 | cannot be reformed, it shall be severed from this Public License 376 | without affecting the enforceability of the remaining terms and 377 | conditions. 378 | 379 | c. No term or condition of this Public License will be waived and no 380 | failure to comply consented to unless expressly agreed to by the 381 | Licensor. 382 | 383 | d. Nothing in this Public License constitutes or may be interpreted 384 | as a limitation upon, or waiver of, any privileges and immunities 385 | that apply to the Licensor or You, including from the legal 386 | processes of any jurisdiction or authority. 387 | 388 | ======================================================================= 389 | 390 | Creative Commons is not a party to its public 391 | licenses. Notwithstanding, Creative Commons may elect to apply one of 392 | its public licenses to material it publishes and in those instances 393 | will be considered the “Licensor.” The text of the Creative Commons 394 | public licenses is dedicated to the public domain under the CC0 Public 395 | Domain Dedication. Except for the limited purpose of indicating that 396 | material is shared under a Creative Commons public license or as 397 | otherwise permitted by the Creative Commons policies published at 398 | creativecommons.org/policies, Creative Commons does not authorize the 399 | use of the trademark "Creative Commons" or any other trademark or logo 400 | of Creative Commons without its prior written consent including, 401 | without limitation, in connection with any unauthorized modifications 402 | to any of its public licenses or any other arrangements, 403 | understandings, or agreements concerning use of licensed material. For 404 | the avoidance of doubt, this paragraph does not form part of the 405 | public licenses. 406 | 407 | Creative Commons may be contacted at creativecommons.org. 408 | 409 | --------------------------------------------------------------------------------