> ## Documentation Index
> Fetch the complete documentation index at: https://doc.lucidworks.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Probability (probability)

export const LwTemplate = ({title = "Key questions to get you started", icon = "sparkles", cta = "Powered by Agent Studio", linkHref = "https://lucidworks.com/demo/?utm_source=docs&utm_medium=referral&utm_campaign=docs_cta_ai"}) => {
  const [isLoaded, setIsLoaded] = useState(false);
  useEffect(() => {
    const timer = setTimeout(() => {
      setIsLoaded(true);
    }, 500);
    return () => clearTimeout(timer);
  }, []);
  return <div className="lw-template-container">
      <Card title={title} icon={icon}>
        {isLoaded && <span dangerouslySetInnerHTML={{
    __html: `<lw-template id="a029c1a9-28be-427e-b0e1-5d918920246a"></lw-template
            >`
  }} />}
        <Link href={linkHref} className="agent-studio-link text-left text-gray-600 gap-2 dark:text-gray-400 text-sm font-medium flex flex-row items-center hover:text-primary dark:hover:text-primary-light group-hover:text-primary group-hover:dark:text-primary-light">Powered by Lucidworks Agent Studio</Link>
      </Card>
    </div>;
};

[localhost link]: http://localhost:3000/docs/4/fusion-server/reference/fusion-sql/probability

[mintlify link]: https://doc.lucidworks.com/docs/4/fusion-server/reference/fusion-sql/probability

[old doc.lw link]: https://doc.lucidworks.com/fusion-server/4.2/3266

The `probability` function calculates the probability that a value drawn from a numeric field will fall within specific range. The `probability` function takes four parameters:

1. the numeric field to compute the probability from
2. the numeric start range
3. the numeric end range
4. the sample size

<LwTemplate />

## Sample syntax

```sql wrap  theme={"dark"}
select probability(sepal_length_d, 5.1, 7.7, 150) as prob
    from iris
```

## Result set

The result set for the `probability` function contains a single record with the calculated probability. The `probability` function returns the probability calculation.

Sample result set in Apache Zeppelin

<img src="https://mintcdn.com/lucidworks/aGMTh7KKUIwUyuv7/assets/images/5.2/udf/probability1.png?fit=max&auto=format&n=aGMTh7KKUIwUyuv7&q=85&s=2e47a7eefc45421379a444c53dd1c954" alt="Sample result" width="1342" height="1116" data-path="assets/images/5.2/udf/probability1.png" />

## Visualization

Sample visualization of the probability function using the Apache Zeppelin number visualization:

<img src="https://mintcdn.com/lucidworks/aGMTh7KKUIwUyuv7/assets/images/5.2/udf/probability2.png?fit=max&auto=format&n=aGMTh7KKUIwUyuv7&q=85&s=4c32784af4d3012db9b5a6e75d275ff1" alt="Sample visualization" width="1338" height="1146" data-path="assets/images/5.2/udf/probability2.png" />
