Point percentile function.

        Example:
            >>> print(chaospy.Iid(chaospy.Uniform(0, 2), 2).inv(
            ...     [[0.1, 0.2, 0.3], [0.2, 0.2, 0.3]]))
            [[0.2 0.4 0.6]
             [0.4 0.4 0.6]]
357917
def _ppf(self, uloc, dist, length, cache):
        
        output = evaluation.evaluate_inverse(
            dist, uloc.reshape(1, -1)).reshape(length, -1)
        assert uloc.shape == output.shape
        return output
1018597
def y_tic_points(self, interval):
        ""
        if type(interval) == FunctionType:
            return interval(*self.y_range)

        return self.y_coord.get_tics(self.y_range[0], self.y_range[1], interval)
989239
def _select_ps(p):
    # There are more generic ways of doing this but profiling
    # revealed that selecting these points is one of the slow
    # things that is easy to change. This is about 11 times
    # faster than the generic algorithm it is replacing.
    #
    # it is possible that different break points could yield
    # better estimates, but the function this is refactoring
    # just used linear distance.
    """"""
    if p >= .99:
        return .990, .995, .999
    elif p >= .975:
        return .975, .990, .995
    elif p >= .95:
        return .950, .975, .990
    elif p >= .9125:
        return .900, .950, .975
    elif p >= .875:
        return .850, .900, .950
    elif p >= .825:
        return .800, .850, .900
    elif p >= .7625:
        return .750, .800, .850
    elif p >= .675:
        return .675, .750, .800
    elif p >= .500:
        return .500, .675, .750
    else:
        return .100, .500, .675
92510
def take_percentile(arr, percent):
    
    size = len(arr)
    stop = min(int(size * percent), len(arr))
    return arr[0:stop]
738455
def cont_r(self, percent=0.9, N=None):
		""""""

		if not hasattr(self, 'F'):
			self.fs_r(N=self.rank)  # generate F
		return apply_along_axis(lambda _: _/self.L[:N], 1,
			   apply_along_axis(lambda _: _*self.r, 0, self.F[:, :N]**2))
363303
def percentile(perc)
      if perc > 100.0 || perc < 0.0
        raise InvalidPercentile, "percentile must be between 0.0 and 100.0"
      end
      return 0.0 if data.empty?

      rank = (perc / 100.0) * (size + 1)

      return data[0]          if rank < 1
      return data[-1]         if rank > size
      return data[rank - 1]   if rank == Integer(rank)
      weighted_average_for(rank)
    end
342524
def _numpy_index_by_percentile(self, data, percentile):
        
        data_perc_low = np.nanpercentile(data, percentile, axis=0, interpolation=self.interpolation)

        indices = np.empty(data_perc_low.shape, dtype=np.uint8)
        indices[:] = np.nan

        abs_diff = np.where(np.isnan(data_perc_low), np.inf, abs(data - data_perc_low))

        indices = np.where(np.isnan(data_perc_low), self.max_index, np.nanargmin(abs_diff, axis=0))

        return indices
347517
def cont_c(self, percent=0.9, N=None):  # bug? check axis number 0 vs 1 here
		""""""

		if not hasattr(self, 'G'):
			self.fs_c(N=self.rank)  # generate G
		return apply_along_axis(lambda _: _/self.L[:N], 1,
			   apply_along_axis(lambda _: _*self.c, 0, self.G[:, :N]**2))
1123463
def uniform_random_global_points(n=100):
    
    xs = np.random.uniform(-180, 180, n)
    ys = np.random.uniform(-90, 90, n)
    return [shapely.geometry.Point(x, y) for x, y in zip(xs, ys)]
1143224
def quantiles(x, qlist=(2.5, 25, 50, 75, 97.5)):
    

    # Make a copy of trace
    x = x.copy()

    # For multivariate node
    if x.ndim > 1:
        # Transpose first, then sort, then transpose back
        sx = sort(x.T).T
    else:
        # Sort univariate node
        sx = sort(x)

    try:
        # Generate specified quantiles
        quants = [sx[int(len(sx) * q / 100.0)] for q in qlist]

        return dict(zip(qlist, quants))

    except IndexError:
        print_("Too few elements for quantile calculation")
274981
function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {
       return (cx - px) * (ay - py) - (ax - px) * (cy - py) >= 0 &&
              (ax - px) * (by - py) - (bx - px) * (ay - py) >= 0 &&
              (bx - px) * (cy - py) - (cx - px) * (by - py) >= 0;
   }
716535
def hyperbola(axes, **kwargs):
    
    opens_up = kwargs.pop('opens_up', True)
    center = kwargs.pop('center', defaults['center'])
    th = N.linspace(0,2*N.pi,kwargs.pop('n', 500))

    vals = [N.tan(th),1/N.cos(th)]
    if not opens_up:
        vals = vals[::-1]

    x = axes[0]*vals[0]+center[0]
    y = axes[1]*vals[1]+center[1]

    extrema = [N.argmin(x),N.argmax(x)]

    def remove_asymptotes(arr):
        arr[extrema] = N.nan
        return arr

    xy = tuple(remove_asymptotes(i) for i in (x,y))

    return xy
518551
def percentiles(self, percentiles):
    """"""
    try:
      scores = [0.0]*len(percentiles)

      if self.count > 0:
        values = self.samples()
        values.sort()

        for i in range(len(percentiles)):
          p = percentiles[i]
          pos = p * (len(values) + 1)
          if pos < 1:
            scores[i] = values[0]
          elif pos > len(values):
            scores[i] = values[-1]
          else:
            upper, lower = values[int(pos - 1)], values[int(pos)]
            scores[i] = lower + (pos - floor(pos)) * (upper - lower)

      return scores
    except IndexError:
      return [float('NaN')] * len(percentiles)
954729
public static <T, U> Collector<T, ?, Optional<T>> percentileBy(double percentile, Function<? super T, ? extends U> function, Comparator<? super U> comparator) {
        if (percentile < 0.0 || percentile > 1.0)
            throw new IllegalArgumentException("Percentile must be between 0.0 and 1.0");

        // At a later stage, we'll optimise this implementation in case that function is the identity function
        return Collector.of(
            () -> new ArrayList<Tuple2<T, U>>(),
            (l, v) -> l.add(tuple(v, function.apply(v))),
            (l1, l2) -> {
                l1.addAll(l2);
                return l1;
            },
            l -> {
                int size = l.size();

                if (size == 0)
                    return Optional.empty();
                else if (size == 1)
                    return Optional.of(l.get(0).v1);

                l.sort(Comparator.comparing(t -> t.v2, comparator));

                if (percentile == 0.0)
                    return Optional.of(l.get(0).v1);
                else if (percentile == 1.0)
                    return Optional.of(l.get(size - 1).v1);

                // x.5 should be rounded down
                return Optional.of(l.get((int) -Math.round(-(size * percentile + 0.5)) - 1).v1);
            }
        );
    }
185697
def calc_percentiles(self, col_name, where_col_list, where_value_list):
        
        #col_data = self.get_col_data_by_name(col_name)
        col_data = self.select_where(where_col_list, where_value_list, col_name)
        #print('calc_percentiles: col_data = ', col_data, ' where_col_list = ', where_col_list, ', where_value_list = ', where_value_list)
        if len(col_data) == 0:
            #print("Nothing to calculate")
            return 0,0,0
        else:
            first  = self.percentile(col_data, .25)
            third  = self.percentile(col_data, .75)
            median = self.percentile(col_data, .50)
            #print('CALC_PERCENTILES =  first, third, median ',  first, third, median )
            return  first, third, median
109953
def _at_percentile(tau, var_tau, percentile):
    
    assert (percentile >= 0.0) and (percentile <= 1.0)
    c_val = _scaling(tau, var_tau)
    k_val = _dof(tau, var_tau)
    return np.sqrt(c_val * chi2.ppf(percentile, df=k_val))
955693
def fit(self, X):
        

        self._X = super().cluster(X)
        candidates = []

        for _ in range(self.n_runs):
            self._init_random_centroids()
            while True:
                prev_clusters = self.clusters
                self._assign_clusters()
                self._move_centroids()

                if np.all(prev_clusters == self.clusters):
                    break

            self._calc_distortion()
            candidates.append((self.distortion, self.centroids, self.clusters))
        
        candidates.sort(key=lambda x: x[0])
        self.distortion = candidates[0][0]
        self.centroids = candidates[0][1]
        self.clusters = candidates[0][2]

        return self