<p>Let me suggest a simple algorithm, where you don't need to know the probabilities that each element in A is chosen (set B in your question).  I assume that each element in A has a known order (for example, each element is a number).</p>
<p>There are two parts to the algorithm.  The first is an algorithm to generate unbiased random bits.  We'll call it &quot;RandomBit()&quot; (Morina et al. 2019).</p>
<ol>
<li>Draw one independent element from A, call it X, and then draw another independent element from A, call it Y.</li>
<li>If X is less than Y, return 0.  If Y is less than X, return 1.  If neither is the case, go to step 1.</li>
</ol>
<p>This works because independent pairs of independent draws from A are statistically indifferent (Montes Gutiérrez 2014, De Schuymer et al. 2003); see the appendix to my <a href="https://peteroupc.github.io/randextract.html" rel="nofollow noreferrer">Note on Randomness Extraction</a> for details.</p>
<p>Next is an algorithm to generate a uniform random number in [0, 1].  All you have to do is &quot;juxtapose enough random binary digits&quot; (von Neumann 1951):  Add RandomBit()/2 + RandomBit()/4 + RandomBit()/8 + ....</p>
<p>If your non-uniform distribution is the normal distribution, see the following question on <em>Cross Validated</em> for further tricks: <a href="https://stats.stackexchange.com/questions/117689">https://stats.stackexchange.com/questions/117689</a></p>
<p>REFERENCES:</p>
<ul>
<li>Von Neumann, J., &quot;Various techniques used in connection with random digits&quot;, J. Res. Nat. Bur. Stand. Appl. Math. Series 3, 36-38 (1951).</li>
<li>Morina, G., Łatuszyński, K., et al., &quot;<a href="https://arxiv.org/abs/1912.09229" rel="nofollow noreferrer">From the Bernoulli Factory to a Dice Enterprise via Perfect Sampling of Markov Chains</a>&quot;, arXiv:1912.09229 [math.PR], 2019.</li>
<li>Montes Gutiérrez, I., &quot;Comparison of alternatives under uncertainty and imprecision&quot;, doctoral thesis, Universidad de Oviedo, 2014.</li>
<li>De Schuymer, Bart, Hans De Meyer, and Bernard De Baets. &quot;A fuzzy approach to stochastic dominance of random variables&quot;, in International Fuzzy Systems Association World Congress 2003.</li>
</ul>
Convert non-uniform pseudorandom generation to uniform?
<p>Lets say I have a function which is non uniform and generates elements in the set A. I have a set B that has the probability of generation of each element in A. Is there any way I can make the non uniform pseudorandom function behave like a uniform pseudorandom function.</p>