ap_rand( integer $min, integer $max, weight $weight )

Description #

Utility function for getting random values with weighting.

Parameters #

  • $min
    integer (Required) Minimum integer.
  • $max
    integer (Required) Maximum integer.
  • $weight
    weight (Required) Weight of random integer.

Source #

File: includes/functions.php

function ap_rand( $min, $max, $weight ) {
	$offset = $max - $min + 1;
	return floor( $min + pow( lcg_value(), $weight ) * $offset );

1 Comment

  1. anspress.io is fantastic, i will come back here for sure


Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment