How to Generate and Plot Random Real Numbers in Mathematica?

Click For Summary
SUMMARY

This discussion focuses on generating and plotting random real numbers in Mathematica, specifically using the function RandomReal[{1,20},1000000] to create one million random numbers between 1 and 20 in under five seconds. The user aims to integrate these random numbers into a function defined by Integrate[sigma[x]^2,x] and plot the results against a specified range. The conversation emphasizes the importance of clear instructions for executing mathematical tasks in programming.

PREREQUISITES
  • Familiarity with Mathematica programming language
  • Understanding of random number generation techniques
  • Knowledge of integration in calculus
  • Basic plotting functions in Mathematica
NEXT STEPS
  • Explore the RandomReal function in Mathematica for advanced usage
  • Learn about numerical integration techniques in Mathematica
  • Investigate plotting functions and options in Mathematica
  • Study the concept of defining functions and variables in Mathematica
USEFUL FOR

Mathematica users, mathematicians, data analysts, and anyone interested in generating random numbers and visualizing mathematical functions.

sola maths
Messages
8
Reaction score
0
Hi,

I'm trying to write a short code in Mathematica that can generate random real numbers in - say 5 secs, and then plot this against any specified range I want. An additional complexity is that the function I'm generating the random numbers for is embedded in an integral. Here's an example of the algorithm:

From time t = 1 to 5;
Generate random real numbers for f = Integrate[sigma[x]^2,x]
Store f in another variable (say z)

Plot all values in z against a specified range
 
Last edited:
Physics news on Phys.org


I am trying to understand what you are asking for

You can do something like
RandomReal[{1,20},1000000]
and that will generate 1000000 random reals between 1 and 20. It might be able to finish that in five seconds.

But you have time and an integral and sigma and x. I cannot tell how those have anything to do with each other. And what does plotting against a range have to do with anything in your steps 1,2,3,4?

Suppose you have to write down a set of simple instructions for a person who knows some mathematics and will follow directions. The person is going to take those instructions, go in the back room and do exactly what those instructions are. This person needs to be able to understand exactly what to do. You don't want him to try to do what he thinks you want, bring it back to you and then you say "well that wasn't what I meant, let me give you a completely different set of instructions" and possibly even repeat this again and again and again until he gets close to understanding what you want.

If you were the person given the instructions in your original post and you didn't know anything about what was wanted except the directions in that post, would you be able to know how to produce the desired result?
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K