Quantcast
Channel: Creating a fast random array generator - Mathematica Stack Exchange
Viewing all articles
Browse latest Browse all 5

Answer by David G. Stork for Creating a fast random array generator

$
0
0

A stylistic suggestion: Never use the variable $N$, which is a function in Mathematica that gives the real value of an expression.

n = 10^3;ii = 174;n (#/Total[#] & /@ Table[Min[RandomReal[],ii/n], {n}, {n}])

This should be fast enough:

n = 10^3;Timing[n (#/Total[#] & /@ Table[Min[RandomReal[],ii/n], {n}, {n}]);]

(* {0.451378, Null} *)


Viewing all articles
Browse latest Browse all 5

Trending Articles