Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This is a sigmoid function in PHP.
<?php
function sigmoid($t){
return 1 / (1 + pow(M_EULER, -$t));
}
?>
@mickrip

This comment has been minimized.

Copy link

@mickrip mickrip commented Jun 27, 2013

I happened to google this looking to use a signoid curve. I found yours didn't work, but this did.

<?php
function sigmoid($t){
    return 1 / (1 + exp(-$t));
}
?>
@digitalgrease

This comment has been minimized.

Copy link

@digitalgrease digitalgrease commented Apr 6, 2016

The problem with it is M_EULER should be M_E.

@raymondjplante

This comment has been minimized.

Copy link

@raymondjplante raymondjplante commented Oct 3, 2016

Both work (with M_E, that is). Anyone happen to have softmax PHP function handy?

@raymondjplante

This comment has been minimized.

Copy link

@raymondjplante raymondjplante commented Oct 4, 2016

Wrote a basic softmax in case anyone's interested: https://gist.github.com/raymondjplante/d826df05349c1d4350e0aa2d7ca01da4

@ai-a

This comment has been minimized.

Copy link

@ai-a ai-a commented Feb 8, 2019

Thanks a million! was looking for this function! so simple!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment