I used statistical language R to fit probability distribution to acquired data. Instead of doing it by hand I relied on code. I wrote something like "probability density function was computed using programming language R (for more details see appendix A)". And appendix A has exact code to compute this. I also put reference to R package documentation. Is it bad to rely external tools for proof?

  • 5
    What do papers in your target journal usually do? Do that.
    – 410 gone
    Jul 8 '15 at 18:56
  • I don't see how R will proof you anything. It might do statistical calculations for you, and if those are used in your paper I'd append the code in the appendix (if there is room).
    – fgysin
    Jul 9 '15 at 6:55
  • IMO programs proves nothing, as programs can have bugs which mimic "correct" answers. Alternatively, the (subliminal) desire of the author to have a program produce "correct" answers can cause the author to write a program which produces the "correct" answer, irregardless of the "correctness" of the paper. Dec 7 '15 at 13:43

From what I can guess about the context, I would avoid putting the code in your paper unless:

  1. the code is really short (say no more than half a column);
  2. the code is interesting in itself;
  3. and you know that your average reader understands the language R.

Otherwise, it would probably better to omit the code altogether and write, in a note, something like:

To those interested, the authors can provide the R code employed to compute the probability density functions described in this work.

  • You're probably right. 2 and 3 are false in my case.
    – pusheax
    Jul 8 '15 at 21:45
  • 2
    Rather than "can provide", though, point to a URL where the code is already up....
    – Danica
    Jul 9 '15 at 1:46

It's very common to include code when code was used. That being said, it's not clear whether you should think of this as "proof" of something in a rigorous mathematical sense, or whether is constitutes evidence in your argument. How accepted this is will depend on the community you are trying to convince.

  • I do think of this as exact proof that PDF is correctly chosen. Because this language is open source, anyone can see what I did in a few sentences of code. This constitutes proof as much as saying according to Theorem so and so. I just do not want to clutter paper with excessive statements. And I think that no one does that among my peers - that's why I asked.
    – pusheax
    Jul 8 '15 at 21:44
  • 1
    @pusheax, how can it be exact proof if it was done with floating-point arithmetic in R? At best it approximates the PDF numerically.
    – Bill Barth
    Jul 8 '15 at 22:00
  • exact proof that it's the best fit among several chosen distributions. But I see your point about FP arithmetic. I could have a case with two PDFs being close to data but I had not.
    – pusheax
    Jul 8 '15 at 22:24

It is fine to put it in your appendix / supplemental info, but it's not really necessary. Computing something as simple as a PDF should be easy for anyone. It's along the lines of including your work to convert from atomic units to Joules. However, enough people have forgotten to normalize correctly so there's nothing bad about including it.


You can put the source code in the appendix but it is not necessary.

1). For it to really matter that there is code in the appendix the read would need to have a basic understanding of programming to at least get the general idea.Other wise as soon as they see something like randomCode = NSString.format"string here"; they are so lost they'll skip over it.

2).If the length of the code is short and doesn't take up much space then even if the reader doesn't understand it you could use it as a "Hey this is the code" and not take up too much space for something the reader may have no understanding of. If the code is lengthy and takes up too much room (this is all dependent of the overall length of all of the other content) then even if the reader is a code junkie it's just too much.

3). You could post the code or at least parts of it and then explain what it actually means for example "This algorithm above is what takes all of the students grades and compiles them from a numeric value into a letter grade.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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