Question

Using Mathematica programming -- I need the program to run 8 times and get 8 different...

Using Mathematica programming -- I need the program to run 8 times and get 8 different outputs-

I only get one output -- I think I need to use the For loop function -- don't know how to insert into program. Help.

Clear["Global`*"]

numCoinFlips = 500 (* This is the # of coin flips. *)
x[1] = 0;

For[n = 1, n < numCoinFlips + 1,
y[n] = Sign[RandomReal[{-1, 1}]];
(* y[n] is the sequence of coin flips. *)
x[n + 1] = x[n] + y[n];
n = n + 1
]

Table[x[n], {n, 1, numCoinFlips}]
Position[Table[x[n], {n, 1, numCoinFlips}], 0] --This lines tells me what position do I find the zero's on output

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Clear["Global`*"]

numCoinFlips = 500 (* This is the # of coin flips. *)
x[1] = 0;

For(i=0, i<8,i++)

[

For[n = 1, n < numCoinFlips + 1,
y[n] = Sign[RandomReal[{-1, 1}]];
(* y[n] is the sequence of coin flips. *)
x[n + 1] = x[n] + y[n];
n = n + 1
]

]

Table[x[n], {n, 1, numCoinFlips}]
Position[Table[x[n], {n, 1, numCoinFlips}], 0]

just use the for loop for 8 times

Add a comment
Know the answer?
Add Answer to:
Using Mathematica programming -- I need the program to run 8 times and get 8 different...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • write the solution of the program by python 3 language : I need the program using...

    write the solution of the program by python 3 language : I need the program using list : You are given a sequence of n positive integers a1,a2,…,an, where n is even. Swap adjacent elements in the given sequence and print the resulting sequence: a2,a1,a4,a3,a6,a5,… Input The first line contains a positive even integer n (2≤n≤1000) — the length of the sequence. The second line contains n space-separated integers a1,a2,…,an (1≤ai≤1000) — the elements of the sequence. Output Print n...

  • I need the programming to be in language C. I am using a program called Zybook...

    I need the programming to be in language C. I am using a program called Zybook Prompt: Write a statement that outputs variable numObjects. End with a newline. Given: #include <stdio.h> int main(void) { int numObjects; scanf("%d", &numObjects); return 0; } What I did so far. I am not sure if its right tho? #include <stdio.h> int main(void) { int numObjects; scanf("%d", &numObjects); printf(" num Objects is "); printf("%d\n", userAge); return 0; }

  • PLEASE. ANSWER ONLY IN MATHEMATICA, THESE PROBLEMS CAN ONLY BE DONE IN MATHEMATICA. I NEED THEM TO BE DONE STRICTLY IN MATHEMATICA. WILL DOWN VOTEIF NOT DONE IN MATHEMATICA!!!!! (thank you in advance)...

    PLEASE. ANSWER ONLY IN MATHEMATICA, THESE PROBLEMS CAN ONLY BE DONE IN MATHEMATICA. I NEED THEM TO BE DONE STRICTLY IN MATHEMATICA. WILL DOWN VOTEIF NOT DONE IN MATHEMATICA!!!!! (thank you in advance) Lab Exercise 1. Solve: (4xy3 - cos y -e ")dx + (6x2y* +xsin y 3) dy 0 2. Solve the initial value DE: (Cos(x)Sincx)- xy2 )dk + y(l-)dy-0, y(o)-2 3. a. Determine a function M(x y) so that the following DE is exact: Mx, y) dx +(xe+...

  • write the solution of the program by python 3 language : I need the program using...

    write the solution of the program by python 3 language : I need the program using list or string or loops (while and for) or if,elif,else : i have 15 min to submit the solution please help me   You are given a sequence of n non-zero integers a1,a2,…,an. Determine if the given sequence contains a pair of adjacent elements of the same sign (both negative or both positive). Two elements are called adjacent if they stand next to each other...

  • In c programming, I need to write a program that reverses each of the lines in...

    In c programming, I need to write a program that reverses each of the lines in a file. The program accepts two command line arguments: The first one is the name of the input file The second is the name of the output file If the user didn't give two filenames, display an error message and exit. The program reads in each line of the input file and writes each line in reverse to the output file. Note, the lines...

  • write the solution of the program by python 3 language : I need the program using...

    write the solution of the program by python 3 language : I need the program using list or string or loops (while and for) or if,elif,else : You are given a sequence of n non-zero integers a1,a2,…,an. Determine if the given sequence contains a pair of adjacent elements of the same sign (both negative or both positive). Two elements are called adjacent if they stand next to each other in the sequence. Input The first line contains an integer n...

  • I NEED HELP WITH DEBUGGING A C PROGRAM! PLEASE HEAR ME OUT AND READ THIS. I...

    I NEED HELP WITH DEBUGGING A C PROGRAM! PLEASE HEAR ME OUT AND READ THIS. I just have to explain a lot so you understand how the program should work. In C programming, write a simple program to take a text file as input and encrypt/decrypt it by reading the text bit by bit, and swap the bits if it is specified by the first line of the text file to do so (will explain below, and please let me...

  • Python Programming 4th Edition: Need help writing this program below. I get an error message that...

    Python Programming 4th Edition: Need help writing this program below. I get an error message that says that name is not defined when running the program below. My solution: def main(): filename = "text.txt" contents=f.read() upper_count=0 lower_count=0 digit_count=0 space_count=0 for i in contents: if i.isupper(): upper_count+=1 elif i.islower(): lower_count+=1 elif i.isdigit(): digit_count+=1 elif i.isspace(): space_count+=1 print("Upper case count in the file is",upper_count) print("Lower case count in the file is",lower_count) print("Digit count in the file is",digit_count) print("Space_count in the file is",space_count)...

  • I need this using C++. In this project, you will implement the dynamic programming-based solution to...

    I need this using C++. In this project, you will implement the dynamic programming-based solution to find the longest common subsequence (LCS) of two sequences. Your inputs will be the two sequences (as Strings) and the outputs are the longest common subsequence (printed as a String) and the final matrix (printed as a two-dimensional array) depicting the length of the longest common subsequences (as shown in the slides) for all possible subsequences of the two input sequences. The two input...

  • 1. Give the Python program that computes the square of a number. The number is passed...

    1. Give the Python program that computes the square of a number. The number is passed to the function as a parameter. The output is the square of this number. For example, the function can be used as shown below . . . . n = s q u a r e ( 7 ) . . . 2. Another very useful feature of Python is looping, which is more flexible than that available in BB. For example: while i...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT