<s> """<STR_LIT>""" <EOL> from __future__ import division <EOL> import numpy as np <EOL> from scipy . linalg import norm <EOL> from . _dbp import dbp <EOL> def logsmooth ( X , inBin , nbin = <NUM_LIT:8> , n = <NUM_LIT:3> ) : <EOL> """<STR_LIT>""" <EOL> if not np . prod ( X . shape ) == max ( X . shape ) : <EOL> raise ValueError ( '<STR_LIT>' ) <EOL> if len ( X . shape ) > <NUM_LIT:1> : <EOL> X = np . squeeze ( X ) <EOL> inBin = int ( inBin ) <EOL> N = X . shape [ <NUM_LIT:0> ] <EOL> N2 = int ( np . floor ( N / <NUM_LIT:2> ) ) <EOL> f1 = int ( inBin % nbin ) <EOL> startbin = np . concatenate ( ( np . arange ( f1 , inBin , nbin ) , <EOL> np . arange ( inBin , inBin + <NUM_LIT:3> ) <EOL> ) ) <EOL> i = <NUM_LIT:1> <EOL> while i < n : <EOL> startbin = np . concatenate ( ( startbin , <EOL> np . arange ( startbin [ - <NUM_LIT:1> ] + <NUM_LIT:1> , <EOL> ( inBin + <NUM_LIT:1> ) * ( i + <NUM_LIT:1> ) - <NUM_LIT:1> , nbin ) , <EOL> ( i + <NUM_LIT:1> ) * ( inBin + <NUM_LIT:1> ) - <NUM_LIT:1> + np . arange ( <NUM_LIT:0> , <NUM_LIT:3> ) <EOL> ) ) <EOL> i = i + <NUM_LIT:1> <EOL> startbin = np . concatenate ( ( startbin , np . array ( ( startbin [ - <NUM_LIT:1> ] + <NUM_LIT:1> , ) ) ) ) <EOL> m = startbin [ - <NUM_LIT:1> ] + nbin <EOL> while m < N2 - <NUM_LIT:1> : <EOL> startbin = np . concatenate ( ( startbin , np . array ( ( m , ) ) ) ) <EOL> nbin = np . min ( ( nbin * <NUM_LIT> , <NUM_LIT:2> ** <NUM_LIT:10> ) ) <EOL> m = int ( np . round ( m + nbin , <NUM_LIT:0> ) ) <EOL> stopbin = np . concatenate ( ( startbin [ <NUM_LIT:1> : ] - <NUM_LIT:1> , np . array ( ( N2 - <NUM_LIT:1> , ) ) ) ) <EOL> f = ( ( startbin + stopbin ) / <NUM_LIT:2> ) / N <EOL> p = np . zeros ( f . shape ) <EOL> for i in range ( f . shape [ <NUM_LIT:0> ] ) : <EOL> p [ i ] = dbp ( norm ( X [ startbin [ i ] : stopbin [ i ] + <NUM_LIT:1> ] ) ** <NUM_LIT:2> / <EOL> ( stopbin [ i ] - startbin [ i ] + <NUM_LIT:1> ) ) <EOL> return f , p </s>
