Does any spreadsheet allow you to create your own functions?

I dont use spreadsheets other than Excel, but Excel is capable of doing just about anything using VBA, including custom functions. Check out this article to see a basic example.

Apple iWork Numbers

This cannot be done in Numbers, unfortunately.

Google Apps

Custom functions are supported in Google's spreadsheet, using JavaScript.

LibreOffice Calc

LibreOffice Calc supports custom functions.

Microsoft Excel

Custom functions are possible in Excel, going back at least as far as Excel 2003.

Given that there are several choices, it's hard to know which one to choose.

If you (or your employer) have a prior commitment to a Microsoft-based solution, or (conversely) to an open-source solution, then the decision is basically already made. If you're an Apple fan (as I am) you'll use Numbers whenever possible, and only abandon it when you need features beyond what it provides. But (in my opinion) the solution with the biggest upsides and fewest downsides is Google spreadsheets:

You don't have to worry about (real and perceived) threats from macros in your spreadsheets. You don't have to worry about whether you can share the file with others: you just grant access to anyone you want, and it's "in the cloud" for them whenever they want. Soon you'll even be able to edit your spreadsheets offline.

You're exposing your information to the Google Information Borg (if you even care), and you're giving up some elegance (as compared to Numbers) and a fuller feature set (as compared, at least, to Excel, if not also to the others), but those may not be a big deal.

If, on the other hand, you're already using Excel (as most of us are) and you can live with the downsides of both the risks involved in using macros, and of the annoying warnings to anyone you share your files with, and of the messiness of managing your functions (if you put them in a separate file then you'll need to distribute that to others every time you give them a spreadsheet using those functions, but if you put them inside the file then you'll be doing a whole lot of copying and pasting, and your later improvements won't propagate to earlier spreadsheets) then a very strong case can be made for sticking with Excel. With very little doubt it's the most powerful of the bunch, and it really doesn't have a bad UI by any means.

This is rather simple using Funfun in Excel. Funfun allows you to use JavaScript directly in Excel so that you could define all sorts of functions by yourself. With the help of the Funfun Excel add-in, you could use the data in the spreadsheet and also output data into specific cells.

Basically what you need to do is

1). Insert the Funfun add-in from Office Add-ins store

enter image description here

2). Create a new Funfun or load a sample from Funfun online editor enter image description here

3). Write JavaScrip code or define your own function.

4). Run the code directly in Funfun

I defined a sample function in Funfun online editor that could calculate the probability density using the mean and standard deviation stored in the spreadsheet. You could check this sample on the link below.

You could easily link this sample to your Excel using the Step2) above.

Disclosure: I'm a developer of Funfun.