Module Assign NameStore Str Assign NameStore Str Expr Str Import alias identifier ImportFrom alias identifier ImportFrom alias ImportFrom alias FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad body Expr Str If CompareLt NameLoad Num body Raise Call NameLoad BinOpAdd Str Call NameLoad NameLoad Assign TupleStore NameStore AttributeLoad NameLoad attr If CompareIs NameLoad NameLoad body Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad orelse Assign TupleStore NameStore NameStore NameLoad If BoolOpOr CompareGt NameLoad Call AttributeLoad NameLoad attr NameLoad CompareLt NameLoad Call AttributeLoad NameLoad attr NameLoad body Raise Call NameLoad Str Assign NameStore BinOpSub NameLoad NameLoad Assign NameStore BinOpDiv NameLoad Call NameLoad BinOpSub NameLoad Num Assign NameStore BinOpAdd NameLoad BinOpMult Call AttributeLoad NameLoad attr BinOpAdd NameLoad Num NameLoad Assign NameStore Call AttributeLoad NameLoad attr BinOpDiv BinOpSub NameLoad NameLoad NameLoad Assign NameStore BinOpDiv Num BinOpMult NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr TupleLoad BinOpAdd NameLoad Num For TupleStore NameStore NameStore Call NameLoad NameLoad body Assign NameStore BinOpDiv BinOpMult NameLoad BinOpSub SubscriptLoad NameLoad Index BinOpAdd NameLoad Num SubscriptLoad NameLoad Index NameLoad NameLoad Assign NameStore BinOpDiv BinOpMult NameLoad BinOpSub SubscriptLoad NameLoad Index NameLoad SubscriptLoad NameLoad Index NameLoad NameLoad AugAssignAdd SubscriptStore NameLoad Index NameLoad NameLoad AugAssignAdd SubscriptStore NameLoad Index BinOpAdd NameLoad Num NameLoad Return TupleLoad SubscriptLoad NameLoad Slice Num SubscriptLoad NameLoad Slice Num decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults NameLoad NameLoad body Expr Str Assign TupleStore NameStore NameStore Call NameLoad NameLoad NameLoad keyword NameLoad Assign NameStore BinOpSub SubscriptLoad NameLoad Index Num SubscriptLoad NameLoad Index Num Assign NameStore BinOpSub SubscriptLoad NameLoad Index Num SubscriptLoad NameLoad Index Num Assign NameStore Call AttributeLoad NameLoad attr BinOpDiv UnaryOpUSub NameLoad Num BinOpDiv NameLoad Num NameLoad Assign NameStore BinOpDiv Num BinOpPow NameLoad Num Assign NameStore Call AttributeLoad NameLoad attr BinOpMult NameLoad BinOpPow NameLoad Num Assign NameStore Call AttributeLoad NameLoad attr NameLoad If CompareEq NameLoad Num body Print Str Assign NameStore BinOpDiv NameLoad NameLoad If NameLoad body Assign NameStore Call NameLoad NameLoad NameLoad orelse Assign NameStore Call NameLoad NameLoad NameLoad Return TupleLoad NameLoad NameLoad decorator_list Assign NameStore Num FunctionDef arguments args NameParam NameParam NameParam NameParam defaults Num NameLoad body Expr Str Assign TupleStore NameStore NameStore Call NameLoad NameLoad NameLoad keyword NameLoad keyword NameLoad Assign NameStore BinOpSub SubscriptLoad NameLoad Index Num SubscriptLoad NameLoad Index Num Assign NameStore BinOpMult UnaryOpUSub NameLoad Call AttributeLoad NameLoad attr BinOpAdd NameLoad NameLoad Assign NameStore Call NameLoad NameLoad keyword NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults Num NameLoad body Expr Str Assign NameStore Call AttributeLoad NameLoad attr ListLoad Call AttributeLoad NameLoad attr NameLoad Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr ListLoad Call AttributeLoad NameLoad attr NameLoad Call AttributeLoad NameLoad attr NameLoad Assign TupleStore NameStore NameStore Call NameLoad NameLoad NameLoad keyword NameLoad keyword NameLoad keyword TupleLoad NameLoad NameLoad Assign TupleStore NameStore NameStore Call NameLoad NameLoad NameLoad keyword NameLoad keyword NameLoad keyword TupleLoad NameLoad NameLoad Assign NameStore BinOpSub SubscriptLoad NameLoad Index Num SubscriptLoad NameLoad Index Num Assign NameStore BinOpMult UnaryOpUSub NameLoad Call AttributeLoad NameLoad attr BinOpDiv BinOpAdd NameLoad NameLoad BinOpAdd NameLoad NameLoad Assign NameStore Call NameLoad NameLoad keyword NameLoad Return NameLoad decorator_list
N/A N/A __author__ Olivier Mangin <olivier.mangin@inria.fr> N/A __date__ 02/2011 N/A One dimensional kernel density estimation.
 N/A numpy np scipy convolve convolve_1d scipy.integrate trapz scipy.signal fftconvolve get_bins_1d N/A N/A x nb_bins bounds N/A None N/A N/A Create a grid of nb_bins bins and spread weights into bins
    in the following manner:
    - for n samples,
    - bins are from -x_min to (x_max + delta_x),
    - if sample x is between left = (x_min + i * delta_x) and
      right = (x_min + (i + 1) * delta_x), weight
      (right - x) / (delta_x * n) (resp. (x - left) / (delta_x * n)) is added
      to bin i (resp. i + 1).

    @param x: (n,) shaped array of samples,
    @param nb_bins: number of bins, must be at least 2.
    @param bounds: if supplied (not None (default)), in the form,
        uses (x_min, x_max) = bounds to generate grid and bins.

    @returns (x_min, x_max, delta_x, grid, bins):
        - grid: position of the left border of bins,
        - bins: bins array containing the sum of weights over samples.
     N/A N/A nb_bins 2 N/A N/A N/A ValueError N/A Number of bins must be at least two,  N/A str nb_bins N/A N/A nb_samples N/A x shape N/A N/A bounds None N/A N/A x_min N/A N/A np min x N/A x_max N/A N/A np max x N/A N/A N/A x_min x_max bounds N/A N/A N/A x_min N/A N/A np min x N/A x_max N/A N/A np max x N/A N/A N/A ValueError Wrong bounds. N/A x_range N/A x_max x_min N/A delta_x N/A x_range N/A float N/A nb_bins 1 N/A x_grid N/A x_min N/A N/A N/A np arange N/A nb_bins 1 delta_x N/A x_bins N/A N/A np floor N/A N/A x x_min delta_x N/A weight N/A 1.0 N/A nb_samples delta_x N/A bins N/A N/A np zeros N/A N/A nb_bins 1 N/A N/A i b N/A enumerate x_bins N/A N/A weight_left N/A N/A weight N/A N/A x_grid N/A N/A b 1 N/A x N/A i delta_x N/A weight_right N/A N/A weight N/A N/A x N/A i N/A x_grid N/A b delta_x N/A N/A bins N/A b weight_left N/A N/A bins N/A N/A b 1 weight_right N/A N/A N/A x_grid N/A -1 N/A bins N/A -1 N/A gaussian_kde_1d N/A N/A x h nb_bins fft bounds N/A True None N/A N/A Estimate probability from one dimensional samples, using a Gaussian
    kernel density estimator.

    @param x: samples, given as a (n,) shaped numpy array,
    @param h: width of the Gaussian kernel,
    @param nb_bins: number of grid points to use,
    @param fft: whether to use FFT to compute convolution.

    @returns: (grid, kde) where kde is the bin grid and kde the density
        estimator on a grid twice as large as grid.
     N/A N/A x_grid bins N/A get_bins_1d x nb_bins bounds bounds N/A x_range N/A N/A x_grid N/A -1 N/A x_grid N/A 0 N/A delta_x N/A N/A x_grid N/A 1 N/A x_grid N/A 0 N/A ker_grid N/A N/A np arange N/A N/A x_range 2.0 N/A x_range 2.0 delta_x N/A exp_fact N/A -0.5 N/A h 2 N/A ker N/A N/A np exp N/A exp_fact N/A ker_grid 2 N/A s N/A N/A np sum ker N/A N/A s 0 N/A N/A Warning: window is too short... N/A ker N/A ker s N/A fft N/A N/A kde N/A fftconvolve bins ker N/A N/A kde N/A convolve_1d bins ker N/A N/A x_grid kde N/A N/A EPSILON 1e-14 kde_entropy_gaussian_1d N/A N/A x h nb_bins fft N/A 1000 True N/A N/A Uses Kernel Density Estimator with Gaussian kernel on one
    dimensional samples x and returns estimated entropy.

    @param x: samples, given as a (n,) shaped numpy array,
    @param h: width of the Gaussian kernel,
    @param nb_bins: number of grid points to use,
    @param fft: whether to use FFT to compute convolution.
     N/A N/A grid kde N/A gaussian_kde_1d x h nb_bins nb_bins fft fft N/A delta N/A N/A grid N/A 1 N/A grid N/A 0 N/A plogp N/A N/A kde N/A N/A np log N/A kde EPSILON N/A entropy N/A trapz plogp dx delta N/A entropy N/A kde_KL_divergence_1d N/A N/A x y h nb_bins fft N/A 1000 True N/A N/A Uses Kernel Density Estimator with Gaussian kernel on one
    dimensional samples x and y and returns estimated Kullback-
    Leibler divergence.

    @param x, y: samples, given as a (n,) shaped numpy array,
    @param h: width of the Gaussian kernel,
    @param nb_bins: number of grid points to use,
    @param fft: whether to use FFT to compute convolution.
     N/A min_ N/A N/A np min N/A N/A N/A np min x N/A N/A np min y N/A max_ N/A N/A np max N/A N/A N/A np max x N/A N/A np max y N/A N/A grid kde_x N/A gaussian_kde_1d x h nb_bins nb_bins fft fft bounds N/A min_ max_ N/A N/A grid2 kde_y N/A gaussian_kde_1d y h nb_bins nb_bins fft fft bounds N/A min_ max_ N/A delta N/A N/A grid N/A 1 N/A grid N/A 0 N/A plogp N/A N/A kde_x N/A N/A np log N/A N/A kde_x EPSILON N/A kde_y EPSILON N/A div N/A trapz plogp dx delta N/A div N/A