Message Boards Message Boards

0
|
4840 Views
|
2 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Plot the logistic function

Posted 4 years ago

I want to plot the logistic function

f[x] = L/[1+Exp[-k[x-x(0)]]]

where L, -k and x0 parametrise the curve.I can do this successfully for one parameter at a time, see below, but cannot find a simple way in which to do this for all three parameters together. Could someone show me how to do this avoiding lines of code that I am as yet unfamiliar with, or failing that, lines of annotated code which I can interpret? I'd be very grateful, the logistic curve is such a beautiful thing!

GraphicsRow[
 Table[Plot[L/(1 + Exp[-x]), {x, -3, 3}, PlotTheme -> "Monochrome", 
   AspectRatio -> 1, Axes -> True, AxesStyle -> Arrowheads[0.05], 
   PlotRange -> {{-4, 4}, {-1, 4}}, 
   PlotStyle -> Directive[Thin, Dashed, Blue]], {L, 4}]]
POSTED BY: Anthony Morris
2 Replies

You don't need to write out the definition of the sigmoid yourself. You can just use the built-in function LogisticSigmoid. With FunctionExpand you can transform it into the Exp form if you want:

FunctionExpand[l*LogisticSigmoid[k (x - x0)]]
(*l/(1 + E^(-k (x - x0)))*)
POSTED BY: Sjoerd Smit

If you are not familiar with Manipulate yet, it is not too late:

Manipulate[
 Plot[L/(1 + Exp[-k (x - x0)]), {x, -3, 3},
  PlotTheme -> "Monochrome", AspectRatio -> 1, Axes -> True,
  AxesStyle -> Arrowheads[0.05], PlotRange -> {{-4, 4}, {-1, 4}},
  PlotStyle -> Directive[Thin, Dashed, Blue]],
 {{L, 1}, 0, 4},
 {{k, 1}, 0, 4},
 {x0, 0, 4}]
POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract