4
$\begingroup$

I need help tabulating and visualizing the expression, 0.905*0.1^n)/n!, where n goes from 0 to 100.

I want to store all the values, and use those values to plot a histogram.

I have used NsolveValues[{(0.905*0.1^n)/n!}], but am having issues extracting the data and then using that data to draw a histogram. Please help? I am a beginner so help would be much appreciated!

$\endgroup$
5
  • 2
    $\begingroup$ Welcome to the Mathematica Stack Exchange. Please write a short descriptive title and describe the problem you face in the post body itself. Include enough Mathematica code in copy-paste-able form so that respondents can replicate your problem. The word Dataset has specialized meaning in Mathematica. As a starting point, you can explore the Table command. You can edit your post by clicking on the Edit link under your post and format code using the { } icon once you are in the Edit window. Thanks. $\endgroup$
    – Syed
    Commented Mar 27, 2022 at 5:31
  • $\begingroup$ NDSolveValue is a command for differential equations. What you have provided is not. Is it possible that you forgot to copy some terms in your expression? $\endgroup$
    – bmf
    Commented Mar 27, 2022 at 5:33
  • $\begingroup$ Table command worked, thanks! would appreciate help in plotting the histogram. $\endgroup$ Commented Mar 27, 2022 at 5:42
  • $\begingroup$ You should look up Histogram $\endgroup$
    – bmf
    Commented Mar 27, 2022 at 5:43
  • $\begingroup$ @NarenViswanathanNarenKumar and since I had a look at the data generated by the expression you gave -it's not an equation- I think you will find Chop very useful $\endgroup$
    – bmf
    Commented Mar 27, 2022 at 5:44

2 Answers 2

8
$\begingroup$
Clear["Global`*"]

data = Table[{n, 0.905*0.1^n/n!}, {n, 0, 100}];

Looking at the first elements of the data list

data[[;; 4]]

(* {{0, 0.905}, {1, 0.0905}, {2, 0.004525}, {3, 0.000150833}} *)

There are several ways to plot the data or the function

ListLogPlot[data, Joined -> True]

enter image description here

ListLinePlot[data, ScalingFunctions -> "Log"]

enter image description here

LogPlot[0.905*0.1^n/n!, {n, 0, 100}]

enter image description here

Plot[0.905*0.1^n/n!, {n, 0, 100},
 ScalingFunctions -> "Log"]

enter image description here

DiscretePlot[0.905*0.1^n/n!, {n, 0, 100},
 ScalingFunctions -> "Log"]

enter image description here

$\endgroup$
4
  • $\begingroup$ (+1) I like your creativity and imagination. You demonstrated many useful ways of presenting the data. Out of curiosity, why didn't you do the histogram? $\endgroup$
    – bmf
    Commented Mar 27, 2022 at 5:57
  • $\begingroup$ @bmf - I didn't consider a histogram an appropriate way to reflect the data or the function. $\endgroup$
    – Bob Hanlon
    Commented Mar 27, 2022 at 6:01
  • $\begingroup$ Neither did I, but the author wanted that for some reason. That's why I asked. In any case, nicely done!!! $\endgroup$
    – bmf
    Commented Mar 27, 2022 at 6:02
  • $\begingroup$ Thanks for all the help!! $\endgroup$ Commented Mar 27, 2022 at 15:26
4
$\begingroup$

Check out the answer by @Bob Hanlon for various pictorial representations of the data generated by your expression. Make sure to upvote it as well!!!

Below I am showing you a histogram.

data = Table[(0.9050 .1^n)/n!, {n, 0, 100}] // Chop[#, 10^-5] &;

The above generates data from the expression given and Chops numbers that are $10^{-5}$.

You can check your data

data

{0.905, 0.0905, 0.004525, 0.000150833, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}

In order to get a Histogram

Histogram[data]

histo

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.