adding text above bins of histogram

I have the following histogram:

ClearAll[texture]
texture[ms_ : {Black, White}, m_ : 100] := 
Texture@RegionPlot[True, {x, 0, 1}, {y, 0, 1}, 
MeshFunctions -> {# - #2 &}, Mesh -> m, MeshStyle -> None, 
MeshShading -> ms, Frame -> False, Axes -> False, 
PlotRangePadding -> 0, ImagePadding -> 0, BoundaryStyle -> None];

data1 = {0.157, 0.147, 0.127, 0.110, 0.103, 0.103, 0.053, 0.053, 0.047, 0.040, 0.033, 0.020, 0.003, 0.003};
data2 = {0.008, 0.008, 0.018, 0.029, 0.035, 0.042, 0.049, 0.049, 0.111, 0.111, 0.118, 0.133, 0.144, 0.145};

styles1 = {LightBlue, LightBlue, LightBlue, LightBlue, LightBlue, LightBlue, LightBlue, LightBlue, LightBlue, LightBlue, LightBlue, LightBlue, LightBlue, LightBlue};
styles2 = texture /@ Thread[{White, {LightBlue, LightBlue, LightBlue, LightBlue,LightBlue, LightBlue, LightBlue, LightBlue, LightBlue,LightBlue, LightBlue, LightBlue, LightBlue, LightBlue}}];

{sdata1, sdata2} = MapThread[Style, #] & /@ {{data1, styles1}, {data2, styles2}};

BarChart[{sdata1, sdata2}, BarSpacing -> None, 
PlotTheme -> "Detailed", 
ChartLabels -> {{Style["Experiment", FontFamily -> "Times"], 
Style["Theory", FontFamily -> "Times"]}, None}, 
LabelStyle -> {28, GrayLevel[0]}, ImageSize -> Large, 
ChartElementFunction -> System`BarFunctionDump`TextureBar, 
PlotLabel -> Style["Histogram", FontFamily -> "Times"]]

Which looks like:
enter image description here

How can I add the texts: $p_0$, $p_1$, …, $p_{13}$ above the bins of the histogram in the left side from the left to the right and the same thing for the right histogram from the right to the left?

python – How do I create curved bins in matplotlib polar 2D histogram?

I am plotting a polar 2d histogram in Python 3.7 using matplotlib using the following code:

import numpy as np
import matplotlib.pyplot as plt

# input data
azimut = np.random.rand(3000)*2*np.pi
radius = np.random.rayleigh(9, size=3000)

# binning
rbins = np.linspace(0, radius.max(), 10)
abins = np.linspace(0, 2*np.pi, 10)

# histogram
hist, _, _ = np.histogram2d(azimut, radius, bins=(abins, rbins))
A, R = np.meshgrid(abins, rbins)

# plot
fig, ax = plt.subplots(subplot_kw=dict(projection="polar"))

pc = ax.pcolormesh(A, R, hist.T, cmap='inferno')
fig.colorbar(pc)

plt.show()

To produce the following plot:
Polar 2D Histogram

Due to the larger bin sizes, the polar projection is appearing more like a polygon rather than a circle.

Is there any way to plot this so that the bins appear curved rather than straight? I.E. so that the plot is always circular, regardless of the bin size and doesn’t become polygon-like when bins are larger?

A matplotlib solution would be preferable, but others are welcome.

Thanks very much for any help.

performance tuning – Splitting balls over sized bins

This is strongly related to Splitting a set of integers over a set of bins, but a much simpler case.

If we have $N$ indistinguishable balls and $k$ arbitrarily large distinguishable bins, we know the number of ways to distribute the balls over the bins (allowing for empty bins) is given by a binomial coeffcient

binCounts(balls_, bins_) :=
  Binomial(balls + bins - 1, balls);

and if we want the actual splits, those are given by taking all permutations of integer partitions of $N$ of length $k$

binSplits(balls_, bins_) :=
  Apply(
   Join,
   Permutations(PadRight(#, bins)) & /@
    IntegerPartitions(balls, bins)
   );

Just to show this indeed works

Table(
   Length(binSplits(n, k)) == binCounts(n, k),
   {n, 1, 20},
   {k, 1, 10}
   ) // Flatten // Apply(And)

True

This breaks down, though, when we have sized bins, i.e. each of our $k$ bins has some max number of allowed balls $c_i$. From this math.SE question I’m not expecting there to be a nice closed-form solution for the number of partitions. That doesn’t mean we can’t write an algorithm to generate them.

The naive approach would be to just filter our prior list of solutions

binSplitsSized(balls_, binSizes_) :=
 Block({bins = Length(binSizes), splits},
  splits = Apply(
    Join,
    Permutations(PadRight(#, bins)) & /@
     IntegerPartitions(balls, bins)
    );
  Select(splits, Min(binSizes - #) >= 0 &)
  )

binSplitsSized(10, ConstantArray(3, 5))

{{3, 3, 3, 1, 0}, {3, 3, 3, 0, 1}, {3, 3, 1, 3, 0}, {3, 3, 1, 0, 3}, {3, 3, 0, 
  3, 1}, {3, 3, 0, 1, 3}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2, 1}, {1, 3, 3, 1, 2}, {1, 3, 2, 3, 1}, {1, 3, 2, 1, 3}, {1, 3,
   1, 3, 2}, {1, 3, 1, 2, 3}, {1, 2, 3, 3, 1}, {1, 2, 3, 1, 3}, {1, 2, 1, 3, 
  3}, {1, 1, 3, 3, 2}, {1, 1, 3, 2, 3}, {1, 1, 2, 3, 3}, {3, 2, 2, 2, 1}, {3, 2,
   2, 1, 2}, {3, 2, 1, 2, 2}, {3, 1, 2, 2, 2}, {2, 3, 2, 2, 1}, {2, 3, 2, 1, 
  2}, {2, 3, 1, 2, 2}, {2, 2, 3, 2, 1}, {2, 2, 3, 1, 2}, {2, 2, 2, 3, 1}, {2, 2,
   2, 1, 3}, {2, 2, 1, 3, 2}, {2, 2, 1, 2, 3}, {2, 1, 3, 2, 2}, {2, 1, 2, 3, 
  2}, {2, 1, 2, 2, 3}, {1, 3, 2, 2, 2}, {1, 2, 3, 2, 2}, {1, 2, 2, 3, 2}, {1, 2,
   2, 2, 3}, {2, 2, 2, 2, 2}}

but if the number of bins or balls get even moderately large, this quickly becomes unworkable, since we’re generating the entire Binomial(balls + bins - 1, balls) solution set.

So how can we do better? The easiest initial approach is to just filter our IntegerPartitions off the bat to exclude any unworkable solutions

binSplitsSized2(balls_, binSizes_) :=
 Block({bins = Length(binSizes), max = Max(binSizes), splits},
  splits = Apply(
    Join,
    Permutations(PadRight(#, bins)) & /@
     
     Select(IntegerPartitions(balls, bins), Max(#) <= max &)
    );
  Select(splits, Min(binSizes - #) >= 0 &)
  )

and this can give a significant boost

binSplitsSized(10, ConstantArray(3, 5)) // Length // RepeatedTiming

{0.0018, 101}

binSplitsSized2(10, ConstantArray(3, 5)) // Length // RepeatedTiming

{0.00022, 101}

but can also be very easily stymied

binSplitsSized(10, ConstantArray(10, 1)~Join~ConstantArray(1, 4)) // 
  Length // RepeatedTiming

{0.0019, 16}

binSplitsSized2(10, ConstantArray(10, 1)~Join~ConstantArray(1, 4)) // 
  Length // RepeatedTiming

{0.0018, 16}

So what good approaches are there do better?

How do BINs vulnerabilities work?

Many companies have some BINs where you can enter a fake credit card and get a premium account (the credit card is based on a BIN that only performs or bypasses the license plate).

I want to know how it works?

For example: bin spotify / netflix etc. 5273XXXXXXXX

How can people discover these trash cans? And how / why do they work?

Probability or Statistics – How to Optimize the Number of Bins with Weighted Data Using Multiple Lists?

I'm trying to sort items in multiple lists into groups of weighted data. I can do the single list case based on a previous question. Especially the code under Update in the first answer.

Data = {1, 2, 3, 4, 5, 6, 7, 10};
Container = {0, 2, 4, 6, 8, 10};
Weights = {0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 1.0};

With[{ranges = Partition[bins, 2, 1]},
Total @ Pick[weights, 
     BitXor[UnitStep[Subtract[data, #1]].
Unit Step[Subtract[data, #2]]], 1]& @@@ areas]

what gives the following output:
{0,1, 0,5, 0,9, 1,3, 0}

Now I try to generalize to the following input:

data = {{1, 2, 3, 4, 5, 6, 7, 10}, {3, 5, 6}};
Container = {0, 2, 4, 6, 8, 10};
Weights = {{0,1, 0,2, 0,3, 0,4, 0,5, 0,6, 0,7, 1,0}, {0,4, 0,6, 0,5} };

I can not use the same code because Pick does not handle each list one after the other. However, with this code, I can get the result you want (with the first and second lists listed separately:

With[{ranges = Partition[bins, 2, 1]},
Total @ Pick[weights[[1]].
BitXor[UnitStep[Subtract[data, #1]].
Unit Step[Subtract[data, #2]]][[1]], 1]& @@@ areas]With[{ranges = Partition[bins, 2, 1]},
Total @ Pick[weights[[2]].
BitXor[UnitStep[Subtract[data, #1]].
Unit Step[Subtract[data, #2]]][[2]], 1]& @@@ areas]

{0,1, 0,5, 0,9, 1,3, 0}
{0, 0.4, 0.6, 0.5, 0}

But now I want to generalize to a large number of lists.
I've tried a loop, but when I generalize it to a loop, it does not work:

To the[i = 1, 2, i ++,
With[{ranges = Partition[bins, 2, 1]},
Total @ Pick[weights[[i]].
BitXor[UnitStep[Subtract[data, #1]].
Unit Step[Subtract[data, #2]]][[i]], 1]& @@@ areas]]

How can I generalize it neatly?

Why does Taiwan have an extreme shortage of public waste bins?

After traveling to Taiwan a few times, it felt pretty weird. I've never seen a country like Taiwan that obviously lacks public waste bins. It does not seem to matter in which city, not just the capital, all of these garbage pails seem to be missing, yet the roads remain relatively clean and garbage-free.

At first I called it an eerie feeling and it was not really real. But as my journey progressed, I had to go to nearby stores to throw out the garbage or put it in a bag that I wanted to throw away when I returned to my whereabouts. It has always seemed like the public parks or the night market are the best places to find a decent amount of public rubbish bins. A walk through the shopping streets had the strange feeling of not having room for garbage.

There must be an explanation why this is so – it always feels bad when there is a lack of public trash cans, but the roads are mostly garbage-free. Compare it to a city like San Francisco, where there's a trash can on the streets that can be found on almost every block but still contains garbage (some of which are homeless, but not all).