# After setting the equal probability energy distribution, the sampling does not match the expected

**URL:** <https://openmc.discourse.group/t/after-setting-the-equal-probability-energy-distribution-the-sampling-does-not-match-the-expected/4610>\
**Category:** User Support\
**Created:** [July 25, 2024, 6:06am UTC](https://openmc.discourse.group/t/after-setting-the-equal-probability-energy-distribution-the-sampling-does-not-match-the-expected/4610 "2024-07-25T06:06:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cro](https://avatars.discourse-cdn.com/v4/letter/c/e5b9ba/32.png) [@cro](https://openmc.discourse.group/u/cro)\
**Post date:** [July 25, 2024, 6:06am UTC](https://openmc.discourse.group/t/after-setting-the-equal-probability-energy-distribution-the-sampling-does-not-match-the-expected/4610/1 "2024-07-25T06:06:58Z")

</div>

Hello everyone, I am a beginner in OpenMC. I have set the energy distribution of the source as simply as possible. The code is as follows:

```auto
...

Point = openmc.stats.Point(xyz = (0.0, 0.0, -15.0))
energy_bin = [1,2,3,4,5,6,7,8,9,10,11]
pro_bin = [0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1]

energy = openmc.stats.Tabular(energy_bin, pro_bin, interpolation='histogram')
source = openmc.IndependentSource(space=Point, energy=energy, particle='neutron')

# setting
my_settings = openmc.Settings()
my_settings.run_mode = 'fixed source'
my_settings.source = source
my_settings.particles = 1
my_settings.batches = 1
my_settings.export_to_xml()

```

Then I tested it with `openmc.lib.sample_external_source`,

```auto
openmc.lib.init(output=False)
particles = openmc.lib.sample_external_source(n_samples=20000, prn_seed=1)
openmc.lib.finalize()

e_values = [particle.E for particle in particles]
e_array = np.array(e_values)

```

I perform statistics on the `e_array` and obtain a histogram:

 ![down](https://global.discourse-cdn.com/free1/uploads/openmc/original/2X/f/f610b265bc39d78fe2b304072d216bd645945df3.png)

I don’t know where the problem, shouldn’t it be a completely equal probability sampling?Please help me clarify my doubts, I would be very grateful, thank you  
cro

---

<div class="post-metadata">

**Author:** ![cro](https://avatars.discourse-cdn.com/v4/letter/c/e5b9ba/32.png) [@cro](https://openmc.discourse.group/u/cro)\
**Post date:** [July 25, 2024, 7:13am UTC](https://openmc.discourse.group/t/after-setting-the-equal-probability-energy-distribution-the-sampling-does-not-match-the-expected/4610/2 "2024-07-25T07:13:09Z")

</div>

Now I know where the problem lies, I should add a 0 at the end of `pro-bin`  
`pro_bin = [0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0]`  
If I don’t do this, the result will be strange. I want to know how to explain it?
