Random stacked pellets for a scientific study
I think I might have a solution. I am not sure if it will meet all the requirements, but maybe it will help.

You can achieve the render above by using an awesome add-on called Animation Nodes. 

Here are the instructions:

1.Go to https://github.com/JacquesLucke/animation_nodes, download and install the add-on as you would with any other.

2.Make sure the add-on is enabled and then add the object that we will be instancing into the 3d view. In your case the pellet, I used a cylinder.

3.Switch the screen layout from default to compositing.

4.In the node editor, on the bottom,  click on the animation nodes tree type. It should be on the right of View Select Add Node. Then, click new.

5.Now we are ready to create the node tree. Each node can be added by pressing Shift A and choose it from there or Ctr A and type the name of the necessary node. I will be using the latter.

6.Press Ctr A , type object instancer and select it. Here you can select how many pellets you want and underneath you can select the pellet model itself(where the little cube is).


Click on the object instancer node and press w. You will get a pie menu. Click on Loop through Objects.Now you will get two more nodes: Invoke subprogram(which will be connected to object instancer) and the Loop input.


8.Press Ctr A again and type Object Transforms Output. Check the XYZ checkboxes on Location and Rotation.

9.Now, on the Loop Input node, grab the black socket that has the word Object next to it, click it and drag to the black socket of the Object Transforms Output.

10.Next, press Ctr A and type random vector . Go back to the Loop input node and drag the blue socket from Index to the Seed of Random vector, then from the Vector of Random Vector to Location of Object Transforms Output.

Play around with the scale and node seed of Random Vector to get the positions that you want.


Finally, let's randomize the rotation: Ctr A , type Random Euler, drag the Index of Loop Input to Seed of Random Euler and from the Euler of Random Euler to Rotation of Object Transforms Output.


And that's it, change the values of scale and seeds of both Random Vector and Random Euler until you get the number of pellets you want. If you want to add more pellets, go to the Object Instancer Node and add as many instances as you need.

Hope this was helpful! If you have any other questions about this method please go ahead!